發(fā)表日期:2019-04 文章編輯:小燈 瀏覽次數(shù):3618
步驟1:加載百度地圖js框架
<script?src="http://api.map.baidu.com/api?v=1.4"></script>
步驟2:寫好地圖容器標(biāo)簽,html代碼如下
<style> #mapbox{width:99%;height:500px;overflow:hidden;border:1px?solid?#ccc;} </style> <div?id="mapbox"></div>
步驟3:js初始化地圖并標(biāo)注,坐標(biāo)點(diǎn)拾取地址:http://api.map.baidu.com/lbsapi/getpoint/index.html
<script> var?map?=?new?BMap.Map("mapbox");????????????//?創(chuàng)建Map實(shí)例,必須和地圖容器id一致 var?point?=?new?BMap.Point(113.295299,22.722847);?//?創(chuàng)建點(diǎn)坐標(biāo) map.centerAndZoom(point,16);?????????????????//?初始化地圖,設(shè)置中心點(diǎn)坐標(biāo)和地圖級別,最大19級 map.enableScrollWheelZoom();?????????????????//啟用滾輪放大縮小 map.addControl(new?BMap.NavigationControl()); map.addControl(new?BMap.ScaleControl()); map.addControl(new?BMap.OverviewMapControl()); var?marker?=?new?BMap.Marker(point);???????????????????????? map.addOverlay(marker); var?infoWinOpts?=?{} var?sitetxt="<div?style='text-align:left;color:#333;line-height:25px;'><li>地址:廣東省中山市南頭鎮(zhèn)金灣廣場B座16號?</li><li>電話:0760-22517081</li></div>"; var?infoWin?=?new?BMap.InfoWindow(sitetxt,infoWinOpts); marker.openInfoWindow(infoWin); marker.addEventListener("click",function(){this.openInfoWindow(infoWin);});//注冊點(diǎn)擊事件 </script>
效果如下:
日期:2019-04 瀏覽次數(shù):3523
日期:2019-04 瀏覽次數(shù):3617
日期:2019-04 瀏覽次數(shù):3766
日期:2019-04 瀏覽次數(shù):3489
日期:2019-04 瀏覽次數(shù):3959
日期:2019-04 瀏覽次數(shù):3505
日期:2019-04 瀏覽次數(shù):3752
日期:2019-04 瀏覽次數(shù):4777
日期:2019-04 瀏覽次數(shù):4138
日期:2019-04 瀏覽次數(shù):5449
日期:2019-04 瀏覽次數(shù):2768
日期:2019-04 瀏覽次數(shù):3270
日期:2019-04 瀏覽次數(shù):3445
日期:2019-04 瀏覽次數(shù):3000
日期:2019-04 瀏覽次數(shù):3979
日期:2019-04 瀏覽次數(shù):3546
日期:2019-04 瀏覽次數(shù):3071
日期:2019-04 瀏覽次數(shù):3377
日期:2019-04 瀏覽次數(shù):3180
日期:2019-04 瀏覽次數(shù):3225
日期:2019-04 瀏覽次數(shù):3012
日期:2019-04 瀏覽次數(shù):3077
日期:2019-04 瀏覽次數(shù):3032
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.