引入高德地圖API異步加載

<script type="text/javascript">javascript

function init() {java

  var d = new Date();web

  var map = new AMap.Map(mapDiv, {api

  dragEnable: false,app

  zoomEnable: false,spa

  view:new AMap.View2D({ip

    center: new AMap.LngLat(經度,緯度),it

    mapTypeControl: true,io

    zoom:15function

   })

  });

  var marker = new AMap.Marker({

  position:new AMap.LngLat(經度,緯度)

  });

  marker.setMap(map);

}

function loadScript() {

  var script = document.createElement("script");

  script.type = "text/javascript";

  script.src = "https://webapi.amap.com/maps?v=1.3&key=祕鑰&callback=init";

  document.body.appendChild(script);

}

window.onreadystatechange  = loadScript();

</script>

<div id="mapDiv" style="width:600px;height:400px"></div>

相關文章
相關標籤/搜索