javascript - 手機(jī)網(wǎng)頁(yè)如何,插入地圖 ;并設(shè)置多個(gè)標(biāo)注點(diǎn) ,還可路線查詢
問(wèn)題描述
問(wèn)題解答
回答1:去這些提供地圖的網(wǎng)站上看他們提不提供接口,有的可以用iframe直接引過(guò)來(lái)。
回答2:百度和高德都有相關(guān)的JS api,完全可以解決你的需求http://lbsyun.baidu.com/index...
回答3:這是我在前不久做的項(xiàng)目里給你找來(lái)的,實(shí)現(xiàn)的是把頁(yè)面中的地址名稱轉(zhuǎn)換成經(jīng)緯度坐標(biāo)并在地圖中標(biāo)注出來(lái),里面有你用的到的,要建多個(gè)地圖的話,就多放幾個(gè)<p class='baidumap'></p>,當(dāng)然ID要變一下啦,JS里初始化也復(fù)制一份,map改成map1后面的方法傳參改成新的ID,不復(fù)雜,你自己琢磨琢磨,還不懂的話歡迎加好友,QQ 269144551,一起學(xué)習(xí)探討
上海市黃浦區(qū)北京西路130弄<p class='baidumap'></p>
<script type='text/javascript' src='http://api.map.baidu.com/api?...這里寫(xiě)的你的key,沒(méi)有的話去百度開(kāi)發(fā)者創(chuàng)建一個(gè),免費(fèi)的**'></script><script type='text/javascript'>
//百度地圖api//獲取項(xiàng)目地址信息var product_address = $(’.product-address’).text();//初始化地圖var map = new BMap.Map('allmap');map.centerAndZoom(’上海市’, 12);map.setCurrentCity('上海市');//添加縮放var navigationControl = new BMap.NavigationControl({ // 靠左上角位置 anchor: BMAP_ANCHOR_TOP_RIGHT, // LARGE類(lèi)型 type: BMAP_NAVIGATION_CONTROL_LARGE, // 啟用顯示定位 enableGeolocation: true});map.addControl(navigationControl);// 添加定位控件var geolocationControl = new BMap.GeolocationControl();geolocationControl.addEventListener('locationSuccess');geolocationControl.addEventListener('locationError', function (e) { //定位失敗事件 alert(e.message);});map.addControl(geolocationControl);//獲取地址經(jīng)緯度var geocoder = new BMap.Geocoder();geocoder.getPoint(product_address, function (point) { if (point) {var lng = point.lng;var lat = point.lat;map.centerAndZoom(product_address, 20);var marker = new BMap.Marker(new BMap.Point(121.477904, 31.242809));map.addOverlay(marker); }}, ’上海市’);
</script>
回答4:百度地圖 API 自己看文檔去。
