0

我想只有一個從Web服務自動完成獨特的結果:爲什麼Google的Places服務使用不同屬性(place_id,coords ecc ..)爲我提供兩次相同的城市?

這是我的要求: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=napoli ita&type=(cities)&language=en&key={API_KEY}

,這是響應

{ 
    "predictions": [ 
    { 
     "description": "Naples, Metropolitan City of Naples, Italy", 
     "id": "b2aaa9753e7bab447d0a3f71a2336c8bb96c3cac", 
     "matched_substrings": [ 
     { 
      "length": 6, 
      "offset": 0 
     }, 
     { 
      "length": 3, 
      "offset": 37 
     } 
     ], 
     "place_id": "ChIJ6_p622YIOxMRfriMZcxDOtI", 
     "reference": "ClRCAAAA6jM0wQfsTkmn2G9JhSrJK1XN5mdK0nFiE_iNiSpmOpzWV9E5cE7Bn5hnxEZy7EfQrTm5uDagf82Sjc-6wBhd7ZtYgLUXArJNYcI1WogVH6USEGz0Cao3FSrzmLlNiP5zhqAaFKa_hu7uIBoAvErvdqhSfF-r7QfZ", 
     "structured_formatting": { 
     "main_text": "Naples", 
     "main_text_matched_substrings": [ 
      { 
      "length": 6, 
      "offset": 0 
      } 
     ], 
     "secondary_text": "Metropolitan City of Naples, Italy", 
     "secondary_text_matched_substrings": [ 
      { 
      "length": 3, 
      "offset": 29 
      } 
     ] 
     }, 
     "terms": [ 
     { 
      "offset": 0, 
      "value": "Naples" 
     }, 
     { 
      "offset": 8, 
      "value": "Metropolitan City of Naples" 
     }, 
     { 
      "offset": 37, 
      "value": "Italy" 
     } 
     ], 
     "types": [ 
     "locality", 
     "political", 
     "geocode" 
     ] 
    }, 
    { 
     "description": "Napoli, Metropolitan City of Naples, Italy", 
     "id": "4d33ea47519b8f9c04635b1a9bae12f04197b99d", 
     "matched_substrings": [ 
     { 
      "length": 6, 
      "offset": 0 
     }, 
     { 
      "length": 3, 
      "offset": 37 
     } 
     ], 
     "place_id": "ChIJRw3rhP-wOxMRP2qkGuYBOxo", 
     "reference": "ClRCAAAAZZJtsiAUKI1qcM0-X_srZwzECGVTK4FtCwEVnUxa7xZJOV5VIyjYDXjqZ6miFEQ1_-yge9sGrbYsQAxOUgriaYZj1juHpRJiKijVRFztW40SEFtfe85oDpHJndMpB2KVxw4aFFKZyol4j79xsZ6f6GlA9osp-uSh", 
     "structured_formatting": { 
     "main_text": "Napoli", 
     "main_text_matched_substrings": [ 
      { 
      "length": 6, 
      "offset": 0 
      } 
     ], 
     "secondary_text": "Metropolitan City of Naples, Italy", 
     "secondary_text_matched_substrings": [ 
      { 
      "length": 3, 
      "offset": 29 
      } 
     ] 
     }, 
     "terms": [ 
     { 
      "offset": 0, 
      "value": "Napoli" 
     }, 
     { 
      "offset": 8, 
      "value": "Metropolitan City of Naples" 
     }, 
     { 
      "offset": 37, 
      "value": "Italy" 
     } 
     ], 
     "types": [ 
     "locality", 
     "political", 
     "geocode" 
     ] 
    } 
    ], 
    "status": "OK" 
} 

你可以看到它返回了我同一個城市有不同的地點id,名稱,座標但類型相同。爲什麼這個?

回答

0

看起來谷歌在意大利的同一個省份有兩個同名的地方,導致自動完成中的描述完全相同。

查看地點ID ChIJ6_p622YIOxMRfriMZcxDOtI。

https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJ6_p622YIOxMRfriMZcxDOtI

現在在的地方ID ChIJRw3rhP-wOxMRP2qkGuYBOxo

https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJRw3rhP-wOxMRP2qkGuYBOxo

兩者具有相同的名稱,在同一行政區域的一級和行政區域級別2.行政區域3級不同,但它沒有出現在自動完成的描述中,所以你不能區分這些地方。

我沒有本地知識,所以我不能說這個數據是否正確。如果您認爲這個數據是錯誤的,隨時讓谷歌知道關於這個問題,在此支持頁面中指定:

https://support.google.com/maps/answer/3094088

希望它能幫助!

相關問題