1. Check out our app, Forums for Android! Download and leave feedback here!

Support How to get GPS coordinates in the browser

Discussion in 'Android Devices' started by snakebite, Sep 7, 2009.

  1. snakebite

    snakebite New Member
    Thread Starter
    5

    Aug 8, 2009
    1
    0
    5
    Is it possible to be get GPS coordinates in the browser? I wan to use it in a web page but i can't find any info about that.
     

    Advertisement

  2. jeling

    jeling New Member
    25

    Sep 9, 2009
    4
    0
    25
  3. shadydude

    shadydude Member
    5

    Nov 13, 2009
    6
    0
    5
    That's not true. Gowalla is doing it straight from the browser. Try it yourself: m.gowalla.com
     
  4. shadydude

    shadydude Member
    5

    Nov 13, 2009
    6
    0
    5
    Take a look at this example:

    Where Am I?

    This will not use your gps because you're not asking for high accuracy:

    navigator.geolocation.getCurrentPosition(positionSuccess, positionError);

    If you add the High Accuracy option, it will use the GPS but won't have time to get a lock or self update it if it already has a lock.

    navigator.geolocation.getCurrentPosition(positionSuccess, positionError, { enableHighAccuracy:true });

    To keep updating the position using the GPS signal which will take some seconds to lock you will have to use a line like this:

    navigator.geolocation.watchPosition(positionSuccess, positionError, { enableHighAccuracy:true });

    But in this example you'll end up adding several markers to the map instead of changing its position.

    Good luck!
     
  5. smaryka

    smaryka New Member
    5

    Oct 22, 2010
    4
    0
    5
    I am trying to get geolocation working in WebViews without much luck, so I tried the url provided:

    Where Am I?

    From the device emulator I can't get the geolocation to work even from the Chrome browser. It says "Detecting Location" but comes back with "Your location is currently unknown".

    Is there something about the emulator that works differently? Geolocation is enabled in the browser options. The link works as expected from Firefox on my desktop.

    [​IMG]

    Steve
     

    Attached Files:

  6. smaryka

    smaryka New Member
    5

    Oct 22, 2010
    4
    0
    5
    You need to use an AVM based on the Google APIs, not the Android API's to get geolocation working in the emulator.

    Steve
     
Tags:

Share This Page

Loading...