I’m trying to get user position in Sencha Touch 2:
var geo = new Ext.util.Geolocation({
autoUpdate: true,
allowHighAccuracy: true,
listeners: {
locationupdate: function(geo) {
lat = geo.getLatitude();
lon = geo.getLongitude();
// here comes processing the coordinates
}
}
});
But I’ve got coordinates only from network. There’s no GPS icon on Android device, pointing that I’m using GPS. Also it doesn’t work when I turn off internet connection. How can I enable GPS positioning? In Manifest file GPS is enabled.
I just got bit by this too.
It turns out there’s a bug in Sencha: in Ext.util.Geolocation.parseOption they name the parameter
allowHighAccuracybut the w3c specs name itenableHighAccuracy.I added the following code to my application init to fix that:
For the record: the bug has been reported over a year ago, and
the fix was applied for TOUCH-2804 in a recent build. I don’t know what that means, but sure enough the bug is still in 2.0EDIT: using the approach mentioned above doesn’t work well either. The GPS icon would turn on and off as Exts calls getCurrentPosition repeatedly using a setInterval. The reason for doing this is that
The native watchPosition method is currently broken in iOS5. In my Android targeted application I ended up ditching Ext:util.Geolocation and directely used navigator.geolocation.watchPosition. After that it worked like a charm.