使用Washington, USA 搜索字符串执行Text Search request 我只得到1 个结果,这似乎是WA 州。
请求(使用您自己的 API 密钥):https://maps.googleapis.com/maps/api/place/textsearch/json?query=Washington%2C%20USA&language=en&key=YOUR_API_KEY
结果:
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "Washington, USA",
"geometry" : {
"location" : {
"lat" : 47.7510741,
"lng" : -120.7401385
},
"viewport" : {
"northeast" : {
"lat" : 49.0024442,
"lng" : -116.91558
},
"southwest" : {
"lat" : 45.543541,
"lng" : -124.8489739
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png",
"name" : "Washington",
"photos" : [
{
"height" : 2124,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101488181553592859672\"\u003eArko Bhattacharjee\u003c/a\u003e"
],
"photo_reference" : "ATtYBwLa-P4aH5Uh3rD2CKaZmwb8HyNPWZ1WZUnw_y4iaUouh4B6BKOwAo52kkiBNSfn3MJmkW6Ju50H_e7zhxs5m5oBJva-dywtTv2cF_OgX6COeUfnre_SVmXw1qA4Fof924hSOvutwFnjsO6MJ1R71ozhBfieWrtvN9dSwVbgQbvMu-3y",
"width" : 1440
}
],
"place_id" : "ChIJ-bDD5__lhVQRuvNfbGh4QpQ",
"reference" : "ChIJ-bDD5__lhVQRuvNfbGh4QpQ",
"types" : [ "administrative_area_level_1", "political" ]
}
],
"status" : "OK"
}
通过使用返回的地点 ID ChIJ-bDD5__lhVQRuvNfbGh4QpQ 执行 Place Details request 来仔细检查:
请求(使用您自己的 API 密钥):https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJ-bDD5__lhVQRuvNfbGh4QpQ&language=en&key=YOUR_API_KEY
结果:
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "Washington",
"short_name" : "WA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
}
],
"adr_address" : "\u003cspan class=\"region\"\u003eWashington\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
"formatted_address" : "Washington, USA",
"geometry" : {
"location" : {
"lat" : 47.7510741,
"lng" : -120.7401386
},
"viewport" : {
"northeast" : {
"lat" : 49.00256875707851,
"lng" : -116.9155800245149
},
"southwest" : {
"lat" : 45.54354101516995,
"lng" : -124.8489739457119
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png",
"name" : "Washington",
"photos" : [],
"place_id" : "ChIJ-bDD5__lhVQRuvNfbGh4QpQ",
"reference" : "ChIJ-bDD5__lhVQRuvNfbGh4QpQ",
"types" : [ "administrative_area_level_1", "political" ],
"url" : "https://maps.google.com/?q=Washington,+USA&ftid=0x5485e5ffe7c3b0f9:0x944278686c5ff3ba",
"utc_offset" : -480,
"website" : "http://www.access.wa.gov/"
},
"status" : "OK"
}