【问题标题】:Google Maps API v3 is returning the wrong location (coordinates)Google Maps API v3 返回错误的位置(坐标)
【发布时间】:2012-06-05 07:18:51
【问题描述】:

我正在使用 Google Map GeoCoder v3 (JSON) 获取坐标

Praia do forte
Mata de São João, Bahia 
Brazil

Google Geocoder API找不到,但http://maps.google.com可以找到。

谷歌地图网站
https://maps.google.com/maps?q=Praia+do+forte,+Mata+de+S%C3%A3o+Jo%C3%A3o,+Bahia,+Brazil&ie=UTF-8&hl=en&authuser=0

这是我要进行地理编码的 Google Maps API v3 请求 URL

http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Praia%2Bdo%2Bforte%252C%2BMata%2Bde%2BS%25C3%25A3o%2BJo%25C3%25A3o%252C%2BBahia%2B%252C%2BBrazil

这是回复

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Praia",
               "short_name" : "Praia",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Praia",
               "short_name" : "Praia",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Cape Verde",
               "short_name" : "CV",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Praia, Cape Verde",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 14.97272960,
                  "lng" : -23.47061630
               },
               "southwest" : {
                  "lat" : 14.90016530,
                  "lng" : -23.54284290
               }
            },
            "location" : {
               "lat" : 14.9304640,
               "lng" : -23.5126690
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 14.95202550,
                  "lng" : -23.48065420
               },
               "southwest" : {
                  "lat" : 14.90890030,
                  "lng" : -23.54468380
               }
            }
         },
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

很明显,“Praia”这个词是佛得角的一个城市。

【问题讨论】:

  • 您可以选择输入邮政编码吗?
  • 在网络应用程序中,是的,可以输入邮政编码,但我认为此位置不存在邮政编码。

标签: google-maps google-maps-api-3


【解决方案1】:

API 地理编码器不同于地图地理编码器(请参阅 API 文档中的常见问题解答)。

但是,只需提供足够的信息来识别该地点是否有效: http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Praia+do+forte,Brazil

【讨论】:

  • 有趣的是,提供更少的信息实际上会导致更准确的位置。
猜你喜欢
  • 2014-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-06
  • 1970-01-01
  • 2016-09-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多