Google map loads geojson online

Researched online loading of google map data, recorded https://jsfiddle.net/api/post/library/pure/ Enter image description js coverage, data filling

function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
// todo
    zoom: 14,
    center: {lat: 40.7119402000001, lng: -74.0434486}
  });
  // data
var temp= {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "letter": "G",
                "color": "blue",
                "rank": "7",
                "ascii": "71"
            },
            "geometry": //geojson 格式空间数据 todo
        }
    ]
};
  // NOTE: This uses cross-domain XHR, and may not work on older browsers.
  map.data.addGeoJson(temp);
}

html

<div id="map"></div>
 <!-- Replace the value of the key parameter with your own API key. -->
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=***&language=en&callback=initMap">
</script>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325482571&siteId=291194637