【问题标题】:google maps geocoder not returning locality谷歌地图地理编码器不返回位置
【发布时间】:2016-11-15 14:28:04
【问题描述】:

我的地理编码器以前可以正常工作,但现在它只返回县、州和国家。根据文档 (https://developers.google.com/maps/documentation/geocoding/intro),地理编码器应返回位置(城市)。

正在搜索“Winnetka”... 预期结果:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Winnetka",
               "short_name" : "Winnetka",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "New Trier",
               "short_name" : "New Trier",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Cook County",
               "short_name" : "Cook County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Illinois",
               "short_name" : "IL",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Winnetka, IL, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 42.1282269,
                  "lng" : -87.7108162
               },
               "southwest" : {
                  "lat" : 42.0886089,
                  "lng" : -87.7708629
               }
            },
            "location" : {
               "lat" : 42.10808340000001,
               "lng" : -87.735895
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 42.1282269,
                  "lng" : -87.7108162
               },
               "southwest" : {
                  "lat" : 42.0886089,
                  "lng" : -87.7708629
               }
            }
         },
         "place_id" : "ChIJW8Va5TnED4gRY91Ng47qy3Q",
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

实际结果:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "New Trier Township",
               "short_name" : "New Trier Township",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Cook County",
               "short_name" : "Cook County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Illinois",
               "short_name" : "IL",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "New Trier Township, IL, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 42.1282269,
                  "lng" : -87.71080979999999
               },
               "southwest" : {
                  "lat" : 42.0886089,
                  "lng" : -87.7708629
               }
            },
            "location" : {
               "lat" : 42.10808340000001,
               "lng" : -87.735895
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 42.1282269,
                  "lng" : -87.7108162
               },
               "southwest" : {
                  "lat" : 42.0886089,
                  "lng" : -87.7708629
               }
            }
         },
         "place_id" : "ChIJW8Va5TnED4gRY91Ng47qy3Q",
         "types" : [ "locality", "political" ]
      }
   ],
   "status" : "OK"
}

【问题讨论】:

  • 它在我返回的结果中返回“Winnetka”(带有“types”:[“locality”,“political”])。
  • 我们实际上遇到了同样的问题,即在对地址进行地理编码时未返回城市。
  • geocodezip,您介意发布您的请求吗?我相信您可能正在使用不同的版本,但我还不确定如何更改版本以及哪个版本仍然返回正确的数据。

标签: google-maps


【解决方案1】:

我和你在同一条船上。没有返回您正在搜索的级别。如果您搜索一个位置,它会丢失。如果您搜索 Administrative_area_level_1,它就会丢失。

@geocodezip 在另一个具有相同问题的问题中认为它是特定于服务器的。这种情况有时会发生,通常是在谷歌做出明显改变的时候。虽然现在真的很痛苦,但希望它很快得到解决。

【讨论】:

  • 如果这是真的,那就像 PayPal 停止了 10 美元到 11 美元之间的交易。这是一个愚蠢的怪癖,让我想到切换到 MapBox。
  • 是的,这非常不方便,因为我的应用程序因此而完全损坏。我们对此无能为力。我相信这是真的,因为它昨晚对某些人有效,而对其他人无效。我已经开始听到有关 MapBox 的消息。您对此有何看法?
  • 它现在对你有用吗?我回来做生意了。至少目前是这样。
  • 它又开始工作了。 MapBox 是一个非常合法的系统,尽管它们的定价很难获得企业计划。
  • 有趣。那我得认真看看了。谢谢,很高兴它也再次为您工作!
猜你喜欢
  • 1970-01-01
  • 2012-01-06
  • 1970-01-01
  • 2012-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多