首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Geocode提供区域数据

Geocode提供区域数据
EN

Stack Overflow用户
提问于 2019-09-18 12:15:54
回答 2查看 767关注 0票数 2

我正在使用谷歌的GeoCoding API。

我想要的是英语数据,而不是区域语言数据。

我调用这个API接口链接,从formatted_address =लासुरगावरोड,लसुर,महाराष्ट्र423702,从results键的第一个位置获取results键,该键以印地语表示,数据如下:

代码语言:javascript
复制
{
   "plus_code" : {
      "compound_code" : "W2H6+3M Harsul, Maharashtra, India",
      "global_code" : "7JFQW2H6+3M"
   },
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "लासुरगाव रोड",
               "short_name" : "लासुरगाव रोड",
               "types" : [ "route" ]
            },
            {
               "long_name" : "लसुर",
               "short_name" : "लसुर",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "औरंगाबाद",
               "short_name" : "औरंगाबाद",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "महाराष्ट्र",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "423702",
               "short_name" : "423702",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "लासुरगाव रोड, लसुर, महाराष्ट्र 423702, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 19.9279766,
                  "lng" : 75.011798
               },
               "southwest" : {
                  "lat" : 19.9276098,
                  "lng" : 75.0108685
               }
            },
            "location" : {
               "lat" : 19.9277932,
               "lng" : 75.01133329999999
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : 19.9291421802915,
                  "lng" : 75.0126822302915
               },
               "southwest" : {
                  "lat" : 19.9264442197085,
                  "lng" : 75.0099842697085
               }
            }
         },
         "place_id" : "ChIJRS92AquJ2zsRGIY8TmId5OQ",
         "types" : [ "route" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Lasur",
               "short_name" : "Lasur",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Aurangabad",
               "short_name" : "Aurangabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "423702",
               "short_name" : "423702",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "Lasur, Maharashtra 423702, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 19.9365397,
                  "lng" : 75.0198626
               },
               "southwest" : {
                  "lat" : 19.9104756,
                  "lng" : 74.99952089999999
               }
            },
            "location" : {
               "lat" : 19.9282261,
               "lng" : 75.0114612
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 19.9365397,
                  "lng" : 75.0198626
               },
               "southwest" : {
                  "lat" : 19.9104756,
                  "lng" : 74.99952089999999
               }
            }
         },
         "place_id" : "ChIJqakxlFSI2zsRU2QZ0WNgCMQ",
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "423702",
               "short_name" : "423702",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Aurangabad",
               "short_name" : "Aurangabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Maharashtra 423702, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 19.9812906,
                  "lng" : 75.14881470000002
               },
               "southwest" : {
                  "lat" : 19.7257081,
                  "lng" : 74.7853344
               }
            },
            "location" : {
               "lat" : 19.8539262,
               "lng" : 74.9910112
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 19.9812906,
                  "lng" : 75.14881470000002
               },
               "southwest" : {
                  "lat" : 19.7257081,
                  "lng" : 74.7853344
               }
            }
         },
         "place_id" : "ChIJAVBUmAp43DsRAohUV0LQMO4",
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Aurangabad",
               "short_name" : "Aurangabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Aurangabad, Maharashtra, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 20.6673799,
                  "lng" : 76.04805
               },
               "southwest" : {
                  "lat" : 19.37426,
                  "lng" : 74.58680009999999
               }
            },
            "location" : {
               "lat" : 19.8910826,
               "lng" : 75.1545381
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 20.6673799,
                  "lng" : 76.04805
               },
               "southwest" : {
                  "lat" : 19.37426,
                  "lng" : 74.58680009999999
               }
            }
         },
         "place_id" : "ChIJOV9BNoai2zsRtocWKbhGxs8",
         "types" : [ "administrative_area_level_2", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Maharashtra",
               "short_name" : "MH",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Maharashtra, India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 22.028441,
                  "lng" : 80.890924
               },
               "southwest" : {
                  "lat" : 15.6024121,
                  "lng" : 72.659363
               }
            },
            "location" : {
               "lat" : 19.7514798,
               "lng" : 75.7138884
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 22.028441,
                  "lng" : 80.890924
               },
               "southwest" : {
                  "lat" : 15.6024121,
                  "lng" : 72.659363
               }
            }
         },
         "place_id" : "ChIJ-dacnB7EzzsRtk_gS5IiLxs",
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 35.513327,
                  "lng" : 97.39535869999999
               },
               "southwest" : {
                  "lat" : 6.4626999,
                  "lng" : 68.1097
               }
            },
            "location" : {
               "lat" : 20.593684,
               "lng" : 78.96288
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 35.513327,
                  "lng" : 97.39535869999999
               },
               "southwest" : {
                  "lat" : 6.4626999,
                  "lng" : 68.1097
               }
            }
         },
         "place_id" : "ChIJkbeSa_BfYzARphNChaFPjNc",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}

是否有可能每次只获取English数据,因为我不希望使用区域语言的数据?

编辑:

我最近尝试过什么?

  • 在标头中传递Accept-Language=enAccept-Language=en-US,但不起作用。
  • 尝试了与language=enhl=en,但不起作用。
EN

回答 2

Stack Overflow用户

发布于 2019-09-19 08:41:21

我相信这可能是故意的行为。Google倾向于本地语言在地理编码API响应的情况下,在地址本地语言有相同的字母表与用户语言。

此行为将在以下博客文章中解释。

https://mapsplatform.googleblog.com/2014/11/localization-of-street-addresses-in.html

如果本地语言和用户语言都使用相同的字母表,Geocoding现在将返回街道和地方的本地名称。例如,在巴西搜索一个用户语言设置为英语的地址,现在返回“Avenida Paulista”而不是“Paulista Avenue”。 如果本地语言和用户语言使用不同的字母,Geocoding将返回本地名称,并将其音译为拉丁字母。在某些情况下,可能会返回一个英文翻译,例如,如果没有音译。例如,搜索用户语言设置为日语的El Tahrir Square,现在返回“El-Tahrir Square、Ismailia、Qasr an尼罗河、开罗省、エジプト”,而不是“エジプトカイロ県Qasr an尼罗河,タハリール広場”(旧结果)或“ميدانالتحرير،قصرالنيل،محافظةالقاهرة‬،مصر”(本地名称)。

也许Google检测到您的IP地址位于印度,因此响应更倾向于本地语言。

在我的例子中,当我从我在西班牙的位置执行您的样例请求时,我得到了以下英文响应

https://maps.googleapis.com/maps/api/geocode/json?latlng=22.9997%2C72.6354&key=MY_API_KEY

代码语言:javascript
复制
{
  "plus_code":{
    "compound_code":"XJXP+V5 Ahmedabad, Gujarat, India","global_code":"7JJJXJXP+V5"
  },
  "results":[
    {
      "address_components":[
        {
          "long_name":"BRTS Corridor",
          "short_name":"BRTS Corridor",
          "types":[
            "route"
          ]
        },
        {
          "long_name":"Rabari Colony",
          "short_name":"Rabari Colony",
          "types":[
            "political","sublocality","sublocality_level_2"
          ]
        },
        {
          "long_name":"Amraiwadi",
          "short_name":"Amraiwadi",
          "types":[
            "political","sublocality","sublocality_level_1"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        },
        {
          "long_name":"380008",
          "short_name":"380008",
          "types":[
            "postal_code"
          ]
        }
      ],
      "formatted_address":"BRTS Corridor, Rabari Colony, Amraiwadi, Ahmedabad, Gujarat 380008, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.0048831,"lng":72.63708439999999
          },
          "southwest":{
            "lat":22.9996702,"lng":72.6353833
          }
        },
        "location":{
          "lat":23.0022759,"lng":72.6362362
        },
        "location_type":"GEOMETRIC_CENTER",
        "viewport":{
          "northeast":{
            "lat":23.0048831,"lng":72.6375828302915
          },
          "southwest":{
            "lat":22.9996702,"lng":72.6348848697085
          }
        }
      },
      "place_id":"ChIJ9UjW5mqGXjkR2mRics2aU4I",
      "types":[
        "route"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Rabari Colony",
          "short_name":"Rabari Colony",
          "types":[
            "political","sublocality","sublocality_level_2"
          ]
        },
        {
          "long_name":"Amraiwadi",
          "short_name":"Amraiwadi",
          "types":[
            "political","sublocality","sublocality_level_1"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        },
        {
          "long_name":"380038",
          "short_name":"380038",
          "types":[
            "postal_code"
          ]
        }
      ],
      "formatted_address":"Rabari Colony, Amraiwadi, Ahmedabad, Gujarat 380038, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.009061,"lng":72.6454679
          },
          "southwest":{
            "lat":22.9931311,"lng":72.6254739
          }
        },
        "location":{
          "lat":23.0019153,"lng":72.6343352
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.009061,"lng":72.6454679
          },
          "southwest":{
            "lat":22.9931311,"lng":72.6254739
          }
        }
      },
      "place_id":"ChIJaY70lGuGXjkRp_Y5g5vavs4",
      "types":[
        "political","sublocality","sublocality_level_2"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"380026",
          "short_name":"380026",
          "types":[
            "postal_code"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Ahmedabad, Gujarat 380026, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.0113677,"lng":72.6453252
          },
          "southwest":{
            "lat":22.9891871,"lng":72.60732229999999
          }
        },
        "location":{
          "lat":23.0044623,"lng":72.62575869999999
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.0113677,"lng":72.6453252
          },
          "southwest":{
            "lat":22.9891871,"lng":72.60732229999999
          }
        }
      },
      "place_id":"ChIJ89jUeXOGXjkRICMp0qh6yZg",
      "types":[
        "postal_code"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Amraiwadi",
          "short_name":"Amraiwadi",
          "types":[
            "political","sublocality","sublocality_level_1"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Amraiwadi, Ahmedabad, Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.0137105,"lng":72.645556
          },
          "southwest":{
            "lat":22.989467,"lng":72.61277
          }
        },
        "location":{
          "lat":22.9996728,"lng":72.635381
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.0137105,"lng":72.645556
          },
          "southwest":{
            "lat":22.989467,"lng":72.61277
          }
        }
      },
      "place_id":"ChIJJTsGyhKGXjkR96JPXxPnU-4",
      "types":[
        "political","sublocality","sublocality_level_1"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "locality","political"
          ]
        },
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Ahmedabad, Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.1378156,"lng":72.7053737
          },
          "southwest":{
            "lat":22.9028759,"lng":72.4541115
          }
        },
        "location":{
          "lat":23.022505,"lng":72.5713621
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.1378156,"lng":72.7053737
          },
          "southwest":{
            "lat":22.9028759,"lng":72.4541115
          }
        }
      },
      "place_id":"ChIJSdRbuoqEXjkRFmVPYRHdzk8",
      "types":[
        "locality","political"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Ahmedabad",
          "short_name":"Ahmedabad",
          "types":[
            "administrative_area_level_2","political"
          ]
        },
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Ahmedabad, Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":23.50846,"lng":72.84009999999999
          },
          "southwest":{
            "lat":21.9817599,"lng":71.83994
          }
        },
        "location":{
          "lat":23.022475,"lng":72.5715183
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":23.50846,"lng":72.84009999999999
          },
          "southwest":{
            "lat":21.9817599,"lng":71.83994
          }
        }
      },
      "place_id":"ChIJIxcnN0CEXjkRobQIMyNYLpI",
      "types":[
        "administrative_area_level_2","political"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"Gujarat",
          "short_name":"GJ",
          "types":[
            "administrative_area_level_1","political"
          ]
        },
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"Gujarat, India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":24.705709,"lng":74.4764881
          },
          "southwest":{
            "lat":20.127954,"lng":68.162834
          }
        },
        "location":{
          "lat":22.258652,"lng":71.1923805
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":24.705709,"lng":74.4764881
          },
          "southwest":{
            "lat":20.127954,"lng":68.162834
          }
        }
      },
      "place_id":"ChIJlfcOXx8FWTkRLlJU7YfYG4Y",
      "types":[
        "administrative_area_level_1","political"
      ]
    },
    {
      "address_components":[
        {
          "long_name":"India",
          "short_name":"IN",
          "types":[
            "country","political"
          ]
        }
      ],
      "formatted_address":"India",
      "geometry":{
        "bounds":{
          "northeast":{
            "lat":35.513327,"lng":97.39535869999999
          },
          "southwest":{
            "lat":6.4626999,"lng":68.1097
          }
        },
        "location":{
          "lat":20.593684,"lng":78.96288
        },
        "location_type":"APPROXIMATE",
        "viewport":{
          "northeast":{
            "lat":35.513327,"lng":97.39535869999999
          },
          "southwest":{
            "lat":6.4626999,"lng":68.1097
          }
        }
      },
      "place_id":"ChIJkbeSa_BfYzARphNChaFPjNc",
      "types":[
        "country","political"
      ]
    }
  ],
  "status":"OK"
} 

因此,为了获得英语结果,您应该从位于国外的服务器(例如来自欧洲的服务器)发送请求,或者尝试说服Google您位于印度以外(可能使用VPN)。

我希望这能帮到你!

更新

https://maps.googleapis.com/maps/api/geocode/json?latlng=19.9276734%2C75.0116544&key=MY_API_KEY还为我提供印地语的结果。

注意,结果的类型是“路由”,位置Id是ChIJRS92AquJ2zsRGIY8TmId5OQ

如果我在Geo编码器工具中打开这个位置ID,文本也是印地语。

id%3 92AquJ2zsRGIY8TmId5OQ

如果您执行place请求https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJRS92AquJ2zsRGIY8TmId5OQ&key=YOUR_API_KEY,您将看到该位置的Google地图上的直接链接。

https://maps.google.com/?q=%E0%A4%B2%E0%A4%BE%E0%A4%B8%E0%A5%81%E0%A4%B0%E0%A4%97%E0%A4%BE%E0%A4%B5+%E0%A4%B0%E0%A5%8B%E0%A4%A1,+%E0%A4%B2%E0%A4%B8%E0%A5%81%E0%A4%B0,+%E0%A4%AE%E0%A4%B9%E0%A4%BE%E0%A4%B0%E0%A4%BE%E0%A4%B7%E0%A5%8D%E0%A4%9F%E0%A5%8D%E0%A4%B0+423702,+India&ftid=0x3bdb89ab02762f45:0xe4e41d624e3c8618

谷歌地图中的文字也是印地语。

它看起来像id ChIJRS92AquJ2zsRGIY8TmId5OQ的地方,它代表了一条路线,在谷歌端确实有一个数据问题。

我认为修复它的唯一方法是联系Google支持小组。希望他们能帮助解决这个数据问题。

票数 1
EN

Stack Overflow用户

发布于 2019-09-19 05:26:49

您是否尝试添加区域参数:钥匙

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57992591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档