百度地圖例項

瓜瓜東西發表於2014-05-09
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>百度地圖</title>
</head>
<body>
<div  style=" width:500px; height:500px;" id="baiduMapDiv"></div>
</body>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
<script type="text/javascript">
    var map = new BMap.Map("baiduMapDiv");
	var myGeo = new BMap.Geocoder();
	myGeo.getPoint("華山", function(point){
	  if (point) {
		map.centerAndZoom(point, 17);
		map.addOverlay(new BMap.Marker(point));
		addMapControl();
	  }
	}, "渭南市");

    function addMapControl(){
		map.enableDragging();
		map.enableScrollWheelZoom();
		map.enableDoubleClickZoom();
		var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
		map.addControl(ctrl_nav);
		var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
		map.addControl(ctrl_sca);
    }
</script>
</html>

相關文章