最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Maps JS API - Find name of place given location (latitudelongitude) - Stack Overflow

programmeradmin0浏览0评论

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.

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.

Share Improve this question edited Dec 3, 2011 at 9:01 Saket asked Dec 3, 2011 at 8:53 SaketSaket 46.1k13 gold badges63 silver badges80 bronze badges 3
  • maybe this helps? stackoverflow.com/questions/2296377/… – Philipp Kyeck Commented Dec 3, 2011 at 8: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 Commented Dec 3, 2011 at 8:59
  • Not sure what other specifics are needed, but perhaps the recent edit in the post should help – Saket Commented Dec 3, 2011 at 9:02
Add a comment  | 

3 Answers 3

Reset to default 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.

Reverse geocode is the term you are looking for:

http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-reverse.html

Example:

http://code.google.com/apis/maps/documentation/javascript/services.html#ReverseGeocoding

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

发布评论

评论列表(0)

  1. 暂无评论