views:

478

answers:

3

Visiting www.google.com on the Android browser (or even with an android spoofed user-agent), presents the option to "Share Location". When clicked, it uses the GPS/Cell phone towers to figure out the location. I tried the google.loader.clientLocation but that only works using the IP address.

Is there a method to tap into the Android OS and access GPS data from a regular web application (and not an Android application) similar to the way Google does?

[Perhaps Google uses the Google Gears app on Android to access this data.]

Thanks!

+2  A: 

This is an HTML5 API, and it'll work on Webkit-derivatives, Chrome, and Firefox 3.5 (for now).

ceejayoz
A: 

I was trying that recently and found this forum posting interesting. I did not find a real good way to do this either and it doesn't look like we can do that without writing our own app which opens a browser instance. http://androidforums.com/support/8868-how-get-gps-coordinates-browser.html

hmm
Thanks, this was helpful and it looks like Google Gears is what helps to retrieve the location. Some sample code is here and I will give it a shot soon:http://www.ajaxapp.com/2009/03/25/google-gear-geolocation-api-example-displays-your-location-on-google-map/
eapen
A: 

Here is also a nice example: http://klauskjeldsen.dk/w3c-geolocation-api-html5/

Mike Terry
As of now, Google has the best resource in my opinion, it tries the W3C and if not, it tries Google Gears to get the geolocation: http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
eapen