为什么不能在Google地方api中只使用一个特定的城市?

时间:2015-06-16 09:00:33

标签: javascript google-maps google-maps-api-3 google-places-api

我想只在阿姆斯特丹(荷兰)搜索地址,我尝试了它的边界,在字符串中添加了& input = amsterdam但是stil显示了更多的城市

html:

<input id="autocomplete" name=origin type=text placeholder=Vertreklocatie class="autocomplete">

JS

function initialize() {
    var inputs = document.getElementsByClassName('autocomplete');

    var southWest = new google.maps.LatLng( 52.318274,4.728856 );
    var northEast = new google.maps.LatLng( 52.431157,5.068373 );
    var hyderabadBounds = new google.maps.LatLngBounds( southWest, northEast );

    var options = {
      bounds: hyderabadBounds,
      componentRestrictions: {country: 'nl'},
      types: ['address']  
    };

    for(var i = 0; i < inputs.length; i++){
      new google.maps.places.Autocomplete(inputs[i], options); 
    }
}

google.maps.event.addDomListener(window, 'load', initialize); 

是否只能在一个城市进行搜索?

http://codepen.io/anon/pen/dozZwZ

0 个答案:

没有答案