I am trying to create a very basic HTML5 page that captures geolocation, but I get an error.
Here is what I have inside the <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); }
There is only a button on the page that calls the GetGeo () function.
What I did was delete the .html file on my phone's sdcard. Then I looked at "content: //com.android.htmlfileprovider/sdcard/GetGeo.html" and the page displayed correctly. When I click the button and execute, I get the following error: "The last location provider has been disabled"
I have a couple of questions: 1: Is it wrong to just delete the html file on the SDCard and try to run it there? 2: Is there something basic that I am doing wrong that prevents him from getting geolocation from a mobile browser?
Thanks in advance for your help!
source share