//获取定位信息
var map = new BMap.Map("allmap");
// var point = new BMap.Point(108.95,34.27);
// map.centerAndZoom(point,12);
var geolocation = new BMap.Geolocation();
var th = this;
geolocation.getCurrentPosition(function(r){
alert(JSON.stringify(this.getStatus()))
if(this.getStatus() == BMAP_STATUS_SUCCESS){
if(r.accuracy==null){
alert('accuracy null:'+r.accuracy);
//用户决绝地理位置授权
return;
}else{
alert(r.accuracy);
}
//用户允许地理位置授权
// alert(r.point.lat);
//同意定位 加载列表信息
// th.vehicleList({
// url:'/api/member/vehicle/list',
// latitude:r.point.lat,
// longitude:r.point.lng
// })
}else {
this.hasVehicle = false;
//不同意定位或定位错误 加载全部列表信息 BMAP_STATUS_PERMISSION_DENIED 没有权限。对应数值“6”
// th.vehicleList({
// url:'/api/member/vehicle/list',
// latitude:0,
// longitude:0
// })
}
},{enableHighAccuracy: true})
百度地图API,用户拒绝获取地理位置getStatus()还是等于BMAP_STATUS_SUCCESS
猜你喜欢
转载自blog.csdn.net/weixin_40222803/article/details/80002678
今日推荐
周排行