Export geoJSON data from Google Maps

前端 未结 3 574
灰色年华
灰色年华 2021-02-03 14:41

Is there built-in support or any library to export geoJSON data from the google.maps.Data layer or google.maps.Data.Feature or googl

3条回答
  •  时光取名叫无心
    2021-02-03 15:16

    Hi i would like to share what I did to export geojson data from google maps to an html textarea.

    This was my html view

         

    This was my javascript

         map.data.toGeoJson(function (data) {
                    document.querySelector('#geojson-input').innerHTML = JSON.stringify(data);
                });
    

    The function togeojson which is a function of map.data class, will get all data from the maps and return on object. To display that object on my textarea, I had to convert that object to a string by using JSON.stringify(data);

    Hopes that will help!

提交回复
热议问题