引入百度地圖異步加載

<script type="text/javascript">javascript

function initialize() {java

var map = new BMap.Map('map');api

  var point=new BMap.Point(經度,緯度);app

  map.centerAndZoom(point,15);spa

  map.enableScrollWheelZoom(); ip

  map.enableContinuousZoom();it

  map.addControl(new BMap.NavigationControl());  io

  map.addControl(new BMap.OverviewMapControl()); function

  map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));   map

  var localSearch = new BMap.LocalSearch(map);

  localSearch.enableAutoViewport();      

var marker = new BMap.Marker(point);  

    map.addOverlay(marker);

}

function loadMyScript() {

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

script.src = "http://api.map.baidu.com/api?v=2.0&祕鑰&callback=initialize";

document.body.appendChild(script);

}

window.onreadystatechange = loadMyScript();

</script>

<div id="map" style="width:900px;height:500px"></div>

相關文章
相關標籤/搜索