Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get current latitude and longitude from gps enabled device

I would like to get the latitude and longitude of current location from gps enabled mobile device right from the web browser. May I know is this possible? how to do it? does it require geolocation api? Some coding example would be helpful. Thanks.

like image 618
davidlee Avatar asked Aug 10 '10 18:08

davidlee


People also ask

Can I get my GPS coordinates from my phone?

Google Maps For Android users, Google Maps is the simplest way to either enter latitude and longitude coordinates or to find out your current coordinates. If you want to find your current coordinates, zoom into your location and hold down on the touchpad screen in the map.

How do I find my current geolocation?

getCurrentPosition() Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers. The Geolocation. getCurrentPosition() method is used to get the current position of the device.


1 Answers

Use the HTML5 Geolocation API, here's the official spec and examples.

EDIT

I've updated my answer to include current browser support.

W3C Geolocation API support

Firefox 3.5+
Safari 5.0+
Chrome 5.0+
Opera
iPhone 3.0+
Android 2.0+

· ·
Other phones not listed above use Gears or their own, platform-specific APIs.

  • W3C geolocation API
  • Gears
  • BlackBerry geolocation API
  • Nokia geolocation API
  • Palm geolocation API
  • OMTP BONDI geolocation API

Ahh, will we ever have just one single API? :)

Many thanks to Mark Pilgrim for his awesome post.

like image 134
Marko Avatar answered Nov 05 '22 16:11

Marko