pc端簡(jiǎn)單的定位

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        #vc-map{
            width: 400px;
            height: 400px;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    


    <div id="vc-map"class="qfe_map_wraper" style='border: 1px solid red'>

    </div>
</body>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=fkL7tTtkXzZF7YxeVccfRVwBdmr0pNnS"></script>
<script>
    var map = new BMap.Map("vc-map");
    map.enableScrollWheelZoom(true);
    var myGeo = new BMap.Geocoder();
    // 將地址解析結(jié)果顯示在地圖上,并調(diào)整地圖視野
    myGeo.getPoint("成都高新區(qū)萬(wàn)象南路669號(hào)", function(point){
            if (point) {
                map.centerAndZoom(point, 16);
                map.addOverlay(new BMap.Marker(point));
            }
        },
        "成都市");


        // getPoint(address: String, callback: Function, city: String)  

        // 對(duì)指定的地址進(jìn)行解析。如果地址定位成功,則以地址所在的坐標(biāo)點(diǎn)Point為參數(shù)調(diào)用回調(diào)函數(shù)。否則,回調(diào)函數(shù)的參數(shù)為null。city為地址所在的城市名,例如“北京市”

</script>
</html>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容