1. 程式人生 > >Mui 獲取當前位置及在地圖上顯示

Mui 獲取當前位置及在地圖上顯示

function translatePoint(position){
    var currentLon = position.coords.longitude;
    var currentLat = position.coords.latitude;
    var gpsPoint = new BMap.Point(currentLon,currentLat);
    BMap.Convertor.translate(gpsPoint,2,initMap); //座標轉換
}
function initMap(point){
    map = new BMap.Map("mapDiv"); //建立地圖
    map.addControl(new BMap.NavigationControl());
    map.addControl(new BMap.ScaleControl());
    map.addControl(new BMap.OverviewMapControl());
    map.centerAndZoom(point,15);
    map.addOverlay(new BMap.Marker(point));
  
}