Question

I'm trying to add the core Geolocation Plugin to my Cordova 3.4.0 installation, but it's not working. This specific plugin just doesn't install. The other plugins install fine (device, camera, file etc), but Geolocation doesn't.

I've created the whole installation from the CLI.

cordova create c:\project br.com.project Project
cordova platform add android
cordova build
cordova plugin add org.apache.cordova.geolocation

After that, the plugin should appear in /assets/www/plugins folder, right? But it doesn't appear!

When I type

cordova plugin add org.apache.cordova.device

the Device plugin (and all others) goes right into the /assets/www/plugins folder and the plugin works fine. Only Geolocation doesn't.

Why is this happening?

Was it helpful?

Solution 2

I found the solution! Actually, the problem was solved from the beginning.

When you add Cordova Geolocation Plugin, it doesn't create a new folder anymore. It just add the needed source files and edit the config.xml.

I don't know for sure if this only happens on newer version of Cordova (3.0 +), but here the pluging is working normally.

So, for install the plugin and get it working, you need to:

Add the plugin

cordova plugin add org.apache.cordova.geolocation

and then you can already call the core functions without doing nothing.

navigator.geolocation.getCurrentPosition(geolocationSuccess);

function geolocationSuccess (position) {

alert(position.coords.latitude); }

Than you, Gas Welder!

OTHER TIPS

I recently ran into a problem with geolocation on Android too. After wasting few hours on debugging I discovered that there is no more geolocation plugin for Android. This post suggests that it has been removed in favour of browser built-in implementations. There is a link to the developers discussion where that decision was made. Don't know why wasn't it properly announced though.

Running cordova plugin add... for geolocation now only adds location permissions to the manifest. In earlier versions it did also copy all the necessary code.

If browser implementations work well enough for you, then there is no problem. But if they are not (which is my case, by the way) then you (and me...) would have to look for older versions of Cordova or project backups with all the needed code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top