Geolocation not working on Android



  • I can’t find a reliable way to get the geolocation plugin working on Android. I am using CLI 6.2.0 and v2.4.2 of the plugin. I don’t a “manifest” in my project. I see a config.xml under the Android directory. If I look at that, there is no permissions set for the geolocation plugin. Can someone provide me with a working example?

    Here is my code:

    function getUsersLocation( callback ) {
            
        navigator.geolocation.getCurrentPosition(
            function( position ) {
                geo.lat = position.coords.latitude;
                geo.lon = position.coords.longitude;
                
                if ( typeof callback !== "undefined" && typeof callback === "function" ) {
                    callback();
                }
                    
            },
            geolocationError,
            { maximumAge: 3000, timeout: 10000, enableHighAccuracy: true }
                
        );
    }
    
    function geolocationError( error ) { ... show a dialog... }
    


  • @MoreScratch Are you using Cloud IDE or CLI/LocalKit?



  • @munsterlander I am using the Cloud IDE. However, I created a new project using LocalKit and using the docs here: https://docs.monaca.io/en/sampleapp/tips/gps/ and enabling the Cordova Geolocation plugin and I still can’t get a location.


  • Onsen UI

    @MoreScratch did you remember to go to Settings, then Cordova Plugins on the side menu under Project and enable the Geolocation plugin?



  • @misterjunio yes I have enabled it: 0_1494611659505_Screen Shot 2017-05-12 at 10.53.10 AM.png


Log in to reply