Here's a link to the documentation on the relevant Google Maps API:
http://code.google.com/apis/ajax/documentation/#ClientLocation
It shows an example of how to use it:
/**
* Set the currentState_ and currentCountry_ properties based on the client's
* current location (when available and in the US), or to the defaults.
*/
InTheNews.prototype.setDefaultLocation_ = function() {
this.currentState_ = this.options_.startingState;
if (google.loader.ClientLocation &&
google.loader.ClientLocation.address.country_code == "US" &&
google.loader.ClientLocation.address.region) {
// geo locate was successful and user is in the United States. range
// check the region so that we can safely use it when selecting a
// state level polygon overlay
var state = google.loader.ClientLocation.address.region.toUpperCase();
if (InTheNews.stateNames[state]) {
this.currentState_ = state;
}
}
this.currentCountry_ = "US";
}
And tells you what you will get from it:
When populated, the
google.loader.ClientLocation
object is
populated with the following
metro-level granularity properties:
ClientLocation.latitude
— supplies the low resolution latitude associated with the client's IP address
ClientLocation.longitude
— supplies the low resolution longitude associated with the client's IP address
ClientLocation.address.city
— supplies the name of the city associated with the client's IP address
ClientLocation.address.country
— supplies the name of the country associated with the client's IP address
ClientLocation.address.country_code — supplies the name of the ISO 3166-1 country code associated with the client's IP address
ClientLocation.address.region — supplies the country specific region name associated with the client's IP address