if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition);
} else {
$("#lable").html("Geolocation is not supported by this browser.");
}
//曾经用google地图写的 不知道有没有参考价值
function showPosition(position) {
var geoLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var mapOptions = {
zoom: 15,
center: geoLocation
}
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
for (var i = 0; i < restaurants.length; i++) {
addMarker(position.coords.latitude,position.coords.longitude);
}
function addMarker(position,title) {
var markers = [];
markers.push(new google.maps.Marker({
position: position,
map: map,
animation: google.maps.Animation.DROP,
title:title
})
)
}
}
个人认为这个是因为获取的坐标点本身的问题!
可以使用HTML5自带的那个获取当前坐标,你会发现准多了!
这是百度地图与腾讯地图的差异,你用腾讯地图的接口去转换坐标的位置就准了。
如果可以拿到html5
geolocation,可以用那个。给你一个GCJ02 转 BD09的算法