javascript Google Maps JS API - 查找给定位置的地点名称(纬度/经度)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8366610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Maps JS API - Find name of place given location (latitude/longitude)
提问by Saket
Given a latitude/longitude, how can I get the nameof the place at that location using Google Map's JS API?
给定纬度/经度,如何使用 Google Map 的 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.
这Geocoder.geocode(..)
似乎是要走的路,但我不确定从 API 结果中获取确切位置名称的最佳方法是什么。
回答by J?rgen
Use the Geocoding API for mapping locations to addresses and addresses to locations. http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
使用地理编码 API 将位置映射到地址以及将地址映射到位置。 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.
结果非常准确,但您仍然必须依赖近似值,因为很少能准确测量用户位置。
回答by abcde123483
Reverse geocode is the term you are looking for:
反向地理编码是您正在寻找的术语:
http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-reverse.html
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://code.google.com/apis/maps/documentation/javascript/services.html#ReverseGeocoding
回答by Devaroop
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
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
是 API 调用。确保 latlng 参数中没有空格