Enable geolocation without refreshing the page?
2 answers
Hope this helps someone else. I had the same problems trying to load geoLocation via the Google Maps API in a multi-page phone + JQM app. SetInterval / setTimer didn't work either. The only way I got it was to do a full update and it looks like the app looks broken.
onDeviceReady did not work for me as geolocation was not being called in index.html file
My solution was to not try to trigger geolocation when uploading / downloading geolocation. Instead, insert a button to call the script:
<a href="#" onclick="getLocation();" data-role="button">Get My Location</a>
Then call the geolocation API with Javascript attached to getLocation ()
function getLocation() {
navigator.geolocation.getCurrentPosition(onSuccess ,onError,
{ timeout: 10000, enableHighAccuracy: true } );
var lat;
var lng;
}
0
source to share