I am trying to create a very basic HTML5 page that grabs the geolocation, but I'm getting an error.
Here's what I have inside my 'script' tags:
function GetGeo() {
if (!navigator.geolocation) {
alert("Could not find geolocation");
}
else {
navigator.geolocation.getCurrentPosition(showMap, function (error) { alert("error encountered: " + error.message ); });
}
}
function showMap(position) {
window.alert(position.coords.latitude + ", " + position.coords.longitude);
}
The page just has a button on it, that calls the GetGeo() function.
What I did is dropped the .html file onto the SDCard of my phone. Then, I browsed to "content://com.android.htmlfileprovider/sdcard/GetGeo.html" and the page shows up correctly. When I click the button and execute, I get the following error: "The last location provider was disabled"
I have a couple questions: 1: Is it wrong to just drop the html file on the SDCard and try to run it there? 2: Is there something basic that I'm doing wrong that is not letting it get the geolocation from the mobile browser?
Thanks in advance for any help!
I figured this out: I needed to go into the setting of my mobile browser and check 'Enable Location'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With