I trying to use html5 geolocation on Iphone, but it always returns a error.
var win = function(position) { alert('Everything is fine! ' + position) };
var fail = function(e) { alert('Can\'t retrieve position.\nError: ' + e) };
navigator.geolocation.getCurrentPosition(win, fail);
I testing on IOS Simulator and my device, but doesnt work. On Safari i just can get my position using a wireless internet connection (??).
There's a way to make this work?
Make sure that your Location Services on the device are on for Safari.  Go to Settings > Privacy > Location Services > Safari and make sure it is set to ON.
Then try this code:
function doGPS()
{
    try{
        //position request
        navigator.geolocation.getCurrentPosition( function (position) { 
        alert(position.coords.latitude);
        alert(position.coords.longitude);
        });
    }
    catch(evt)
    {
        alert(evt.message);
    }
}
                        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