Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

navigator.geolocation.GetCurrentPosition throws "The last location provider was disabled" error

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!

like image 439
JSprang Avatar asked Dec 28 '22 23:12

JSprang


1 Answers

I figured this out: I needed to go into the setting of my mobile browser and check 'Enable Location'

like image 136
JSprang Avatar answered Dec 30 '22 13:12

JSprang