10

私の要件は、バンガロールの場所に対してのみ Google の場所のオートコンプリートの提案を取得することですが、バンガロールまたは言及された緯度経度内の場所のみを取得していません。

オートコンプリートテキストフィールドの画像の下の場所のみを撤回したい。

ここに画像の説明を入力

誰かが同じことを達成する方法と私が間違っている場所を提案できますか?

Javascript:

<script type="text/javascript">


   function initialize1() {

    var southWest = new google.maps.LatLng( 12.97232, 77.59480 );
    var northEast = new google.maps.LatLng( 12.89201, 77.58905 );
    var bangaloreBounds = new google.maps.LatLngBounds( southWest, northEast );

    var options = {
        bounds: bangaloreBounds,
        types: ['(cities)'],
        componentRestrictions: {country: 'in'}
    };

     var input = document.getElementById('searchTextFieldTo');
     var autocomplete = new google.maps.places.Autocomplete(input, options);
   }
   google.maps.event.addDomListener(window, 'load', initialize1);
</script>

テキストフィールド:

<input type="text" id="searchTextFieldTo" class="ui-timepicker-hour" style="width:350px;text-align:left;font-style:italic;" placeholder="Enter To location" autocomplete="on" />
4

5 に答える 5

2

これを試すことができると思います。

var bangaloreBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(12.864162, 77.438610),
    new google.maps.LatLng(13.139807, 77.711895));

var autocomplete = new google.maps.places.Autocomplete(this, {
  bounds: bangaloreBounds,
  strictBounds: true,
});

autocomplete.addListener('place_changed', function () {

});

注意フォーム xomena: strictBounds オプションは、現在 (2017 年 1 月) 実験的なバージョンである Maps JavaScript API のバージョン 3.27 で追加されました。

于 2017-01-13T04:08:53.737 に答える
1
function initialize() {

 var bangaloreBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(12.864162, 77.438610),
    new google.maps.LatLng(13.139807, 77.711895));



    var options = {
        bounds: bangaloreBounds,
       
        componentRestrictions: {country: 'in'},
        strictBounds: true,
    };

     var input = document.getElementById('autocomplete');
     var autocomplete = new google.maps.places.Autocomplete(input, options);
   }
   google.maps.event.addDomListener(window, 'load', initialize);
于 2018-04-21T09:06:18.307 に答える