Google地理编码以非预期的语言返回响应

时间:2018-07-02 12:47:37

标签: google-geocoding-api

我对Google地理编码API有疑问。 例如,当我发送链接,其中language = uk时,我收到了这样的response。如我们所见,那里有5个结果对象。第四个对象包含有关乌克兰语言中的国家和地区的信息。第三个对象包含有关乌克兰语言的国家信息和有关英语区域的信息。 为什么我会收到不同语言的信息?

这是结果对象(第三和第四)

      {
     "address_components" : [
        {
           "long_name" : "Lodhran",
           "short_name" : "Lodhran",
           "types" : [ "administrative_area_level_2", "political" ]
        },
        {
           "long_name" : "Punjab",
           "short_name" : "Punjab",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "Пакистан",
           "short_name" : "PK",
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "Lodhran, Punjab, Пакистан",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 29.9698789,
              "lng" : 72.1114551
           },
           "southwest" : {
              "lat" : 29.372238,
              "lng" : 71.35502939999999
           }
        },
        "location" : {
           "lat" : 29.686854,
           "lng" : 71.6673352
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 29.9698789,
              "lng" : 72.1114551
           },
           "southwest" : {
              "lat" : 29.372238,
              "lng" : 71.35502939999999
           }
        }
     },
     "place_id" : "ChIJh7mT2TF3OzkRWljvImnMH-Y",
     "types" : [ "administrative_area_level_2", "political" ]
  },
  {
     "address_components" : [
        {
           "long_name" : "Пенджаб",
           "short_name" : "Пенджаб",
           "types" : [ "administrative_area_level_1", "political" ]
        },
        {
           "long_name" : "Пакистан",
           "short_name" : "PK",
           "types" : [ "country", "political" ]
        }
     ],
     "formatted_address" : "Пенджаб, Пакистан",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 34.0434647,
              "lng" : 75.38186639999999
           },
           "southwest" : {
              "lat" : 27.7051105,
              "lng" : 69.3288726
           }
        },
        "location" : {
           "lat" : 31.1704063,
           "lng" : 72.70971609999999
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 34.0434647,
              "lng" : 75.38186639999999
           },
           "southwest" : {
              "lat" : 27.7051105,
              "lng" : 69.3288726
           }
        }
     },
     "place_id" : "ChIJy5pBdImU3zgRoOxO0hgwnjo",
     "types" : [ "administrative_area_level_1", "political" ]
  }

1 个答案:

答案 0 :(得分:0)

“ uk”代表乌克兰语。根据Google翻译,格式为“ Gojra,Lodhran,旁遮普邦,Пакистан”的乌克兰语为“ Gojra,Lodhran,旁遮普邦,巴基斯坦”。在后端(您从中提取信息),Google使用英语,而不是乌克兰语。但是,由于您指定了language = uk,因此前端显示的信息将以乌克兰语格式设置。