我正在使用Ext.Map
{
xtype: 'map',
height: '100%',
useCurrentLocation: true,
mapOptions: {
zoom: 18
}
}
我如何知道用户拒绝分享他的位置,以便显示错误?
答案 0 :(得分:0)
在mapOptions ::
之后将以下内容添加到mapObjectmapOptions : { . . .
zoom : 18
},
geo:new Ext.util.GeoLocation({
autoUpdate:true,
maximumAge: 0,
timeout:2000,
listeners:{
locationupdate: function(geo) {
center = new google.maps.LatLng(geo.latitude, geo.longitude);
if (map.rendered)
map.update(center)
else
map.on('activate', map.onUpdate, map, {single: true, data: center});
},
locationerror: function (geo,bTimeout, bPermissionDenied, bLocationUnavailable, message) {
if(bLocationUnavailable){
alert('Your Current Location is Unavailable on this device');
}
else if (bPermissionDenied){
alert('Location capabilities have been disabled on this device.');
}
}
}
});