为什么Google浏览器测试定位是准确的 当在移动端测试时偏差就很大 4G网络差了一个城市 wifi差了半个城市
// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398, 39.897445);
map.centerAndZoom(point, 12);
var geoc = new BMap.Geocoder();
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r) {
if(this.getStatus() == BMAP_STATUS_SUCCESS) {
var mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
alert('您的位置:' + r.point.lng + ',' + r.point.lat);
var pt = r.point;
geoc.getLocation(pt, function(rs) {
var addComp = rs.addressComponents;
alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
});
} else {
alert('failed' + this.getStatus());
}
}, {
enableHighAccuracy: true
})
人之初爱撸码
- 发布:2016-10-12 09:09
- 更新:2016-10-12 09:09
- 阅读:1364
0 个回复