1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    120
    Answers
    3
    Vote Rating
    3
    clifficious is on a distinguished road

      0  

    Default 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...

    Code:
    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);
                    }
                }
            }
        });
    and
    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);
        }
    });
    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.
    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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,047
    Answers
    3493
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    120
    Answers
    3
    Vote Rating
    3
    clifficious is on a distinguished road

      0  

    Default


    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
    Code:
    src/device/geolocation/PhoneGap.js
    is not available. It is referenced in device/Geolocation.js in line 54. Looking into the directory it is really missing.

    Is there any reason for this? It seems that Sencha does not have any chance of activating the PhoneGap GPS system.

    After changing
    Code:
    Ext.device.Geolocation.watchPosition
    in my code to
    Code:
    navigator.geolocation.watchPosition
    and commenting out line 54 in devices/Geoloction.js I got the device's GPS module working.

    Ext.device.Geolocation is not initialized, is it?

Thread Participants: 1

Tags for this Thread