-
26 Jun 2012 5:33 AM #1
Unanswered: Difference util.Geolocation and device.Geolocation plus GPS Problem
Unanswered: Difference util.Geolocation and device.Geolocation plus GPS Problem
Hi there,
I was wondering what the difference is between util.Geolocation and device.Geolocation. I tried coding a little example but the output seems to be the same. Also as there is still the bug of not getting the high Accuracy (GPS module) running, I tried using the workaround presented here.
Here is my sample code...
andCode:geo = Ext.create('Ext.util.Geolocation', { autoUpdate: true, allowHighAccuracy: true, frequency: 3000, timeout: 30000, listeners: { locationupdate: function(geo) { var map = Ext.getCmp('map'); latlon = new google.maps.LatLng(geo.getLatitude(), geo.getLongitude()); marker = new google.maps.Marker({ position: latlon, map: map.getMap() }); }, locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) { if(bTimeout){ alert('Timeout occurred.'); } else { alert('Error occurred.'+message); } } } });
There seems to be no difference when using the methods. Also when using it with PhoneGap the GPS is not accessed correctly. After applying the work-around the GPS symbol pops up for less than a second but than vanishes again. After 3 seconds (the frequency) the same happens again. GPS sign blinks and vanishes.Code:watchID = Ext.device.Geolocation.watchPosition({ frequency: 3000, timeout: 30000, allowHighAccuracy: true, callback: function(position) { var map = Ext.getCmp('map'); latlon = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); map.getMap().setCenter(latlon); marker = new google.maps.Marker({ position: latlon, map: map.getMap(), icon : "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=•|117569" }); }, failure: function(e) { console.log('something went wrong!'); console.log(e); } });
Can anybody help me in this issue? Or support me with some working code? Im currently testing it on a Google Nexus phone running Android 4.0.4.
Thanks guys!
Cliff
-
28 Jun 2012 5:19 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3102
Ext.util.Geolocation uses the HTML5 Geolocation. Ext.device.Geolocation uses the device's GPS is it is using the native wrapper else it will use Ext.util.Geolocation
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.
-
28 Jun 2012 5:31 AM #3
in my testapp which I used together with PhoneGap using this tutorial (which is similar to the one for iOS) both method have the same output. But after changing the order of the JS-sources and putting the cordova.js infront of sencha.js I got the error which is thrown because
is not available. It is referenced in device/Geolocation.js in line 54. Looking into the directory it is really missing.Code:src/device/geolocation/PhoneGap.js
Is there any reason for this? It seems that Sencha does not have any chance of activating the PhoneGap GPS system.
After changingin my code toCode:Ext.device.Geolocation.watchPosition
and commenting out line 54 in devices/Geoloction.js I got the device's GPS module working.Code:navigator.geolocation.watchPosition
Ext.device.Geolocation is not initialized, is it?


Reply With Quote