2

Given a latitude/longitude, how can I get the name of the place at that location using Google Map's JS API?

The Geocoder.geocode(..) seems to be the way to go, but am not sure what's the best way to get the exact location name out of the API results.

Saket
  • 45,521
  • 12
  • 59
  • 79
  • maybe this helps? http://stackoverflow.com/questions/2296377/how-to-get-city-name-from-latitude-and-longitude-values-in-google-map-android – Philipp Kyeck Dec 03 '11 at 08:57
  • It's called reverse geocoding. what exactly are you asking? what is the specific problem? google api for this is quite simple. so be more specific. what have you already tried? – alonisser Dec 03 '11 at 08:59
  • Not sure what other specifics are needed, but perhaps the recent edit in the post should help – Saket Dec 03 '11 at 09:02

3 Answers3

8

Use the Geocoding API for mapping locations to addresses and addresses to locations. http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding

Geocoder.geocode( { 'latLng': latLngObject }, callback);

The callback receives results and status.

The results are pretty accurate, but you'll have to rely on approximations nevertheless, as the user location can rarely be measured exactly.

Community
  • 1
  • 1
Jørgen
  • 8,820
  • 9
  • 47
  • 67
  • Jorgen, nice avatar. Is it made automatically from your photo? Which tool did you use? – Tomas Dec 03 '11 at 09:34
  • Yeah, it's pretty cool :) The company I work for order them from an artist. I'm afraid I don't know about how she makes them. – Jørgen Dec 03 '11 at 10:07
  • Yeah, that's really cool. I hoped they not drawn by hand, but generated but that's not the case unfortunatelly. Thank you for info :-) – Tomas Dec 03 '11 at 10:10
3

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

is the API call. MAKE SURE THAT THERE IS NO SPACE IN THE latlng PARAMETER

Devaroop
  • 7,900
  • 2
  • 37
  • 34