私はGoogleのジオコーディングAPIを使用して、カスタマイズされたマップ内の位置の自動補完検索を実現します。GoogleジオコーディングAPI予期しない結果が曖昧な検索クエリ
http://maps.googleapis.com/maps/api/geocode/json?address=frankfurt&components=country[de]
私はちょうど1の結果とバックこの応答を得た:問題は応答がドイツに存在するすべてのフランクフルトが含まれている必要があること、である
{
results: [
{
address_components: [
{
long_name: "Frankfurt am Main",
short_name: "Frankfurt am Main",
types: [
"locality",
"political"
]
},
{
long_name: "Darmstadt",
short_name: "DA",
types: [
"administrative_area_level_2",
"political"
]
},
{
long_name: "Hessen",
short_name: "HE",
types: [
"administrative_area_level_1",
"political"
]
},
{
long_name: "Deutschland",
short_name: "DE",
types: [
"country",
"political"
]
}
],
formatted_address: "Frankfurt am Main, Deutschland",
geometry: {
bounds: {
northeast: {
lat: 50.2272095,
lng: 8.8003977
},
southwest: {
lat: 50.0152145,
lng: 8.4727299
}
},
location: {
lat: 50.1109221,
lng: 8.6821267
},
location_type: "APPROXIMATE",
viewport: {
northeast: {
lat: 50.2272095,
lng: 8.8003977
},
southwest: {
lat: 50.0152145,
lng: 8.4727299
}
}
},
place_id: "ChIJxZZwR28JvUcRAMawKVBDIgQ",
types: [
"locality",
"political"
]
}
],
status: "OK"
}
は、私はそのような要求を行います。 (フランクフルト、メイン+フランクフルト、オーダー)。しかし、それはちょうどフランクフルト、メインと応答します。他の地名でも同じことが起こります。理論では少なくとも2回は存在するはずです。しかしGoogleはちょうど1つを示す。おそらく最も関連性の高いものでしょう。
これを修正する方法はありますか?または、別のジオコードサービスを使用することをお勧めしますか?
コンポーネントフィルタを使用しようとしましたが、何も変更されませんでした。
xomenaの答えは、すべてのものをカバーしていますが、国[de]は正しくフォーマットされておらず無視されるので、country = de – miguev