【问题标题】:Inconsistent administrative_area_level_1 geocode for same city (accented)同一城市的行政区域级别 1 地理编码不一致(重音)
【发布时间】:2015-04-29 15:02:35
【问题描述】:

在客户报告标题中提到的错误之前,我的简单应用一直运行良好。 Google 有时会返回去除重音的结果:

{
           "long_name" : "Hanoi",
           "short_name" : "Hanoi",
           "types" : [ "administrative_area_level_1", "political" ]
        }

还有重音:

 {
           "long_name" : "Hà Nội",
           "short_name" : "Hà Nội",
           "types" : [ "administrative_area_level_1", "political" ]
        }

我尝试过应用 API 密钥(语言 = 法语),但没有成功。

结果,我按城市、地区分组地址的逻辑失败了!

顺便说一句,你们有什么好的提示可以使用来自谷歌地理编码或任何其他提供商的数据自动将地址分组到地区、城市、国家/地区

谢谢

【问题讨论】:

    标签: google-maps geolocation geocoding google-geocoding-api


    【解决方案1】:

    如果您希望将法语作为结果数据的语言,您必须在请求的 语言 参数中提及这一点。

    但是,要将地址分组到地区城市和国家/地区,您可以使用以下 API 请求。

    https://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&language=fr&key=API_KEY
    

    在您的 district 将是 administrative_area_level_2 的响应中,states 将是administrative_area_level_1country 将是 country 参数。

    我正在为上述请求发布 JSON。

    {
    results: [1]
    0:  {
    address_components: [5]
    0:  {
    long_name: "Winnetka"
    short_name: "Winnetka"
    types: [2]
    0:  "locality"
    1:  "political"
    -
    }-
    1:  {
    long_name: "New Trier"
    short_name: "New Trier"
    types: [2]
    0:  "administrative_area_level_3"
    1:  "political"
    -
    }-
    2:  {
    long_name: "Comté de Cook"
    short_name: "Comté de Cook"
    types: [2]
    0:  "administrative_area_level_2"
    1:  "political"
    -
    }-
    3:  {
    long_name: "Illinois"
    short_name: "IL"
    types: [2]
    0:  "administrative_area_level_1"
    1:  "political"
    -
    }-
    4:  {
    long_name: "États-Unis"
    short_name: "US"
    types: [2]
    0:  "country"
    1:  "political"
    -
    }-
    -
    formatted_address: "Winnetka, Illinois, États-Unis"
    geometry: {
    bounds: {
    northeast: {
    lat: 42.1282269
    lng: -87.71081629999999
    }-
    southwest: {
    lat: 42.0886089
    lng: -87.7708629
    }-
    }-
    location: {
    lat: 42.10808340000001
    lng: -87.735895
    }-
    location_type: "APPROXIMATE"
    viewport: {
    northeast: {
    lat: 42.1282269
    lng: -87.71081629999999
    }-
    southwest: {
    lat: 42.0886089
    lng: -87.7708629
    }-
    }-
    }-
    place_id: "ChIJW8Va5TnED4gRY91Ng47qy3Q"
    types: [2]
    0:  "locality"
    1:  "political"
    -
    }-
    -
    status: "OK"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-24
      • 2011-09-11
      • 2012-05-07
      • 2012-01-13
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多