Google map在线加载geojson

研究了在线加载google map 数据,记录下 https://jsfiddle.net/api/post/library/pure/ 输入图片说明 js 覆盖,数据填充

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>

猜你喜欢

转载自my.oschina.net/u/3781121/blog/1621408