Google-maps geolocation


#1

Hi,
I’m making an application that uses Google Maps.
App works fine in the browser, but Android device doesn’t
allow me to use geolocation.
Does anyone know what the problem is?


#2

There should be some permissions that you have to include in your android.manifest file.
Here’s an article from google about setting up the maps api. Basically your looking for the references to the mainfest file


#3

@ns01 did you install geolocation plugin for cordova/phonegap?


#4

Ok. I have included permissions in AndroidManifest.xml and config.xml
but it still does not work.
I use build.phonegap.com to build my app. Can that be a mistake?
Do you know some good tutorial “How to build android app with ionic step by step” ?


#5

I also have some problem with geolocation; i have try the new ng-cordova.js, the i have installed the cordova geolocation plugin.
My controller is very simple (and it work fine in Chrome)

.controller(‘DashCtrl’, function($scope,$cordovaGeolocation) {
$cordovaGeolocation.watchPosition().then(function (resp) {
}, function (err) {
}, function (position) {
$scope.lat = position.coords.latitude;
$scope.lng = position.coords.longitude;
});

    $scope.getLatLng = function () {
        if (!$scope.lat && !$scope.lng) {
            return '???';
        }
        return $scope.lat.toFixed(3) + ', ' + $scope.lng.toFixed(3);
    }

});

(Installing “org.apache.cordova.geolocation” for android); all work fine into the web browser, but in a device simulator not work.
When i have run ionic build android, the scrpt has made the permission in the android.manifest.xml: these are the line added

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

but in the device (i use genymotion) the controller for getting the coords don’t work…
Thank you


#6

abmcr :

I am testing with genymotion too and after updating config.xml and AndroidManifest.xml as found on different forums, I realized that the gps was not ON in the emulator when using genymotion… just switched ON and it worked.


#7

Try adding geolocation plugin with the nodejs command line

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

$ stands for the directory in which your app is developed