Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
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.
-
@MoreScratch did you remember to go to
Settings
, thenCordova Plugins
on the side menu underProject
and enable theGeolocation
plugin?
-
@misterjunio yes I have enabled it: