0

我正在使用 Ext.Map

{
    xtype: 'map',
    height: '100%',
    useCurrentLocation: true,
    mapOptions: {
        zoom: 18
    }
}

我如何知道用户拒绝分享他的位置以便我可以显示错误?

4

1 回答 1

0

在您的 mapOptions :: 之后将以下内容添加到您的 mapObject

mapOptions : { . . . 
  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.');
            }      
        }
    }
});
于 2013-03-26T20:32:27.793 回答