views:

95

answers:

1

Does the city method only work in Firefox? for example if I wanted to print the city of the user:

  if (navigator.geolocation)
  {
    navigator.geolocation.getCurrentPosition(function(location) {
      document.write(location.address.city);
    });
  }

If this is true, what's the best way to find a users city? Take the lat and long and plug it into google's location api?

A: 

no, it works in all major browsers.

Look here for an example, which does seem to do what you suggested

var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

also, a simple google search would've given you the same info in ~15 secs :)

asymmetric
I am asking specifically about the location.address.city method. It can be found in the mozilla documentation under nsIDOMGeoPositionAddress. Is the address interface only available in firefox?
agentargo