Geo
Geo

Reputation: 96767

How can I ask for user location the way google maps does it?

If I go to the google maps homepage, there's a button there with my location. If I press it, the browser asks me if I want to share my location with google. I know of the V3 API's google.loader.ClientLocation, but this isn't asking me anything related to location sharing.

Upvotes: 2

Views: 3397

Answers (1)

Trott
Trott

Reputation: 70065

Check the documentation at http://code.google.com/apis/maps/documentation/javascript/basics.html#Geolocation.

The key piece of code you need to use is:

navigator.geolocation.getCurrentPosition(successCallback);

It can take an errorCallback as an optional second parameter.

Upvotes: 3

Related Questions