before I integrated my Ionic-based application with Crosswork getting geolocation information is functioning well. But when I used Crosswork it speeds up my app and functioning well except with the geolocation. I cannot get the latitude/longitude but there is no error alerted in my app.
My code is the same.
var onSuccess = function(position) {
localStorage.latitude = position.coords.latitude;
localStorage.longitude = position.coords.longitude;
};
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
This feature seems to have been noticed by the crosswalk dev team and has had a bout of fixes so should now be working on most devices. See this thread for details.
The most obvious solution that you must try/verify is that you have enabled location service on your device!
SETTINGS -> LOCATION -> Enable location (GPS/WIFI)
This is definitely the case for me, however, if you find yourself on an unsupported device (see thread above) then you will have several options...
Best of luck.
i've noticed the same. the browser based navigator.geolocation object doesn't work from cordova with the crosswalk container for some reason.
you can install the geolocation plugin for cordova.
cordova plugin add cordova-plugin-geolocation
this solved the problem for me, no code rewriting needed as it replaces the same navigator object.
If you use Android, you should Google Play Services