根據您描述的用例,這聽起來像您使用了錯誤的API。
如果您有地址,並且希望Google地圖可以爲您解析並返回額外信息,則應該使用the Geocoding API。您可以確定結果是否有street_number
,以便您可以判斷結果是否包含完整地址。例如:
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
會給你這樣的結果:
{
"results" : [
{
"address_components" : [
{
"long_name" : "1600",
"short_name" : "1600",
"types" : [ "street_number" ]
},
{
"long_name" : "Amphitheatre Parkway",
"short_name" : "Amphitheatre Pkwy",
"types" : [ "route" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Santa Clara County",
"short_name" : "Santa Clara County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "94043",
"short_name" : "94043",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
"geometry" : {
"location" : {
"lat" : 37.4223455,
"lng" : -122.0841893
},
"location_type" : "ROOFTOP",
"viewp.....
給你一個street_number
,所以你可以告訴它是一個完整的地址。
我想你使用錯誤的API密鑰。 –
不,我使用我的API密鑰,但我不能在這裏寫,因爲它不公開。如果我使用錯誤的API密鑰,我不會得到任何結果。但是我確實得到了結果,我只是想確保我得到房子的街道(不僅是街道) –
您在此期間是否找到了針對您問題的解決方案? – mikrobi