Google provides a way to get the user location via it's AJAX API loader. This will even work without Gears installed. Simply include a script tag pointing to the JsAPI:
<script type="text/javascript"
src="http://www.google.com/jsapi?key=ABCDEFG">
</script>
When an application makes use of the AJAX API loader, the loader attempts to geo locate the client based on it's IP address. If this process succeeds, the client's location, scoped to the metro level, is made available in the google.loader.ClientLocation property. If the process fails to find a match, this property is set to null.
if (google.loader.ClientLocation){
var center = new google.maps.LatLng(
google.loader.ClientLocation.latitude,
google.loader.ClientLocation.longitude
);
map.setCenter(center);
}
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