-
30 Mar 2012 11:41 AM #1
Answered: Ext.device.Geolocation in native build not working on iOS
Answered: Ext.device.Geolocation in native build not working on iOS
Hi,
I'm using the Ext.device.Geolocation Class to get the current Location. When I run the app as a web app via safari on iPad 1 everything works fine. If I package the exactly same app as a native app for iOS and deploy this app on my iPad1, then the callback I defined in Ext.device.Geolocation.getCurrentPosition() does not fire. I get no Location. I use the following code:
Code:showMyLocation: function(){ Ext.device.Geolocation.getCurrentPosition({ success: function(position){ var myPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var map = this.getMapPanel().down('map').getMap(); var marker = new google.maps.Marker({ position: myPosition }); marker.setMap(map); }, failure: function(){ Ext.Msg.alert("Fehler", "Positionsbestimmung nicht möglich!", Ext.emptyFn); }, timeout: 10000, scope: this }); },
-
Best Answer Posted by pwr4563
I now use a workaround. Mayby this could help other people facing the same problem like I do. Instead of Ext.device.Geolocation I use Ext.util.Geolocation for getting a Location in the native iOS Build on iPad1.
The following code I use:
I did not find any other solution that works on iPad1. On Android native Build and in the mobile Safari Browser everthing works fine.Code:showMyLocation: function(){ if(Ext.device.Device.platform == 'iPad'){ var geo = Ext.create('Ext.util.Geolocation', { autoUpdate: true, listeners: { locationupdate: function(geo){ var myPosition = new google.maps.LatLng(geo.getLatitude(), geo.getLongitude()); var map = this.getMapPanel().down('map').getMap(); var marker = new google.maps.Marker({ position: myPosition }); if(this.getMapPanel().myLocationMarker != null){ this.getMapPanel().myLocationMarker.setMap(null); } marker.setMap(map); this.getMapPanel().myLocationMarker = marker; }, locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message){ Ext.Msg.alert("Error:", message, Ext.emptyFn); }, scope: this } }); geo.updateLocation(); }else{ Ext.device.Geolocation.watchPosition({ callback: function(position){ var myPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var map = this.getMapPanel().down('map').getMap(); var marker = new google.maps.Marker({ position: myPosition }); if(this.getMapPanel().myLocationMarker != null){ this.getMapPanel().myLocationMarker.setMap(null); } marker.setMap(map); this.getMapPanel().myLocationMarker = marker; }, failure: function(){ Ext.Msg.alert("Fehler", "Positionsbestimmung nicht möglich!", Ext.emptyFn); }, frequency: 10000, scope: this }); } },
-
30 Mar 2012 11:48 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3109
What iOS version?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Mar 2012 11:49 AM #3
-
3 Apr 2012 4:13 AM #4
I now use a workaround. Mayby this could help other people facing the same problem like I do. Instead of Ext.device.Geolocation I use Ext.util.Geolocation for getting a Location in the native iOS Build on iPad1.
The following code I use:
I did not find any other solution that works on iPad1. On Android native Build and in the mobile Safari Browser everthing works fine.Code:showMyLocation: function(){ if(Ext.device.Device.platform == 'iPad'){ var geo = Ext.create('Ext.util.Geolocation', { autoUpdate: true, listeners: { locationupdate: function(geo){ var myPosition = new google.maps.LatLng(geo.getLatitude(), geo.getLongitude()); var map = this.getMapPanel().down('map').getMap(); var marker = new google.maps.Marker({ position: myPosition }); if(this.getMapPanel().myLocationMarker != null){ this.getMapPanel().myLocationMarker.setMap(null); } marker.setMap(map); this.getMapPanel().myLocationMarker = marker; }, locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message){ Ext.Msg.alert("Error:", message, Ext.emptyFn); }, scope: this } }); geo.updateLocation(); }else{ Ext.device.Geolocation.watchPosition({ callback: function(position){ var myPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var map = this.getMapPanel().down('map').getMap(); var marker = new google.maps.Marker({ position: myPosition }); if(this.getMapPanel().myLocationMarker != null){ this.getMapPanel().myLocationMarker.setMap(null); } marker.setMap(map); this.getMapPanel().myLocationMarker = marker; }, failure: function(){ Ext.Msg.alert("Fehler", "Positionsbestimmung nicht möglich!", Ext.emptyFn); }, frequency: 10000, scope: this }); } },
-
18 May 2012 6:42 AM #5
I have the same issue. tested on iOs 5.1.1 (iPodTouch and iPad 2).
Everything from the Ext.device Collection (Camera, Notification, ...) works except Geolocation. I've build my application with Sencha SDK 2.0 BETA 3 on Windows 7.
If i use Ext.device.Geolocation the application crash, without any notifcation.


Reply With Quote