Wednesday, January 18, 2012

current location needs page refresh in Jquery mobile


i have created an application in jquery and google maps javascript v3 , in which i am displaying a user's current location after a button click.



Now the problem is some times i got pretty fine current location and sometimes at the same place its showing my current location miles away but again when i refresh the page i again got the pretty fine current location.



does anyone know how to get rid off pressing refresh button again so a user doesn't has to press the refresh on their mobile browser ??



Note: I am testing this application in android phone which has a default browser.



Page #1 has a button and Page #2 has a map but the Page #1 and Page #2 are combined in a single jQuery HTML page.

1 comment:

  1. Why don't you try adding some logic using the accuracy parameter off the geolocation object (position.coords.accuracy). For example,

    //if accuracy is to low
    if (position.coords.accuracy =< 500) {
    //redo the geolocation
    navigator.geolocation.getCurrentPosition(function(position) {
    //update marker
    marker.setPosition(new google.maps.LatLng(position.coords.latitude, position.coords.longitude)})
    }
    , displayError);
    }

    ReplyDelete