</script>
<title>城市名定位</title>
</head>
<body>
<div?id="allmap"></div>
<div?id="r-result">
經(jīng)度:?<input?id="longitude"?type="text"?style="width:100px;?margin-right:10px;"?/>
緯度:?<input?id="latitude"?type="text"?style="width:100px;?margin-right:10px;"?/>
<input?type="button"?value="查詢"?onclick="theLocation()"?/>
</div>
</body>
</html>
<script?type="text/javascript">
//?百度地圖API功能
var?map?=?new?BMap.Map("allmap");
map.centerAndZoom(new?BMap.Point(114.520253,38.047547),11);
map.enableScrollWheelZoom(true);
//?用經(jīng)緯度設(shè)置地圖中心點(diǎn)
function?theLocation(){
if(document.getElementById("longitude").value?!=?""?&&?document.getElementById("latitude").value?!=?""){
map.clearOverlays();?
var?new_point?=?new?BMap.Point(document.getElementById("longitude").value,document.getElementById("latitude").value);
var?marker?=?new?BMap.Marker(new_point);??//?創(chuàng)建標(biāo)注
map.addOverlay(marker);??????????????//?將標(biāo)注添加到地圖中
map.panTo(new_point);??????
}
if(map.centerAndZoom(new?BMap.Point(114.533007,38.094281),15));{var?marker?=?new?BMap.Marker(point);??//?創(chuàng)建標(biāo)注
map.addOverlay(marker);??????????????//?將標(biāo)注添加到地圖中
map.centerAndZoom(point,?15);
var?opts?=?{
??width?:?200,?????//?信息窗口寬度
??height:?100,?????//?信息窗口高度
??title?:?"海底撈王府井店"?,?//?信息窗口標(biāo)題
??enableMessage:true,//設(shè)置允許信息窗發(fā)送短息
??message:"親耐滴,晚上一起吃個飯吧?戳下面的鏈接看下地址喔~"
}
var?infoWindow?=?new?BMap.InfoWindow("地址:北京市東城區(qū)王府井大街88號樂天銀泰百貨八層",?opts);??//?創(chuàng)建信息窗口對象?
marker.addEventListener("click",?function(){??????????
map.openInfoWindow(infoWindow,point);?//開啟信息窗口
});}
}
</script>
用百度地圖輸入坐標(biāo)設(shè)置出一個覆蓋物然后點(diǎn)擊覆蓋物顯示信息但是彈框不能彈出來。。。求大神指教?。?!可以的話可否連把坐標(biāo)框放在地圖上側(cè)的代碼編寫也填上,感激不盡?。?!
荇箜下的楓
2015-10-26 22:02:45