検索に Google マップ API を実装しました。私のコードは自動生成された場所まで正常に動作していますが、書式文字列全体ではなく都市名のみを提供することで正確な場所を取得できる機能が必要です。
例:
この画像を確認してくださいhttp://demo.ncryptedprojects.com/nct_bnb_clone_new/Untitled.png
検索ボックスにムンバイという都市名を入力すると、Google マップ API がドロップダウンのすべての値を取得します。誰かがドロップダウンから値を選択せず、都市名の後に直接Enterキーを押すと、地図で都市ムンバイを正確に検索できません。私が正確にやりたいことは、誰かが都市名を入力して検索すると、「ムンバイ マハラシュトラ、インド」のようなドロップダウンから最初に出現したものを自動的に検索することです。
HTMLフォーム
<input name="location" id="location" type="text"/>
Google マップ API
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
$(function() {
var e;
e = $('.search-form input[name="location"]')[0];
return new google.maps.places.Autocomplete(e, {
types: ["geocode"]
})
});