【发布时间】:2017-04-12 02:31:09
【问题描述】:
我的要求是只为班加罗尔的地点获取谷歌地点自动完成建议,但如果我搜索班加罗尔以外的任何其他地点,那么我也会得到我不想要的建议。我发现了许多与我的问题相关的 stackoverflow 链接,但没有一个能解决我的问题。
这可以得到任何特定城市的建议吗?
我在下面分享我的代码:-
var input = (document.getElementById('address'));
var s_w = new google.maps.LatLng( 12.97232, 77.59480 ); //southwest
var n_e = new google.maps.LatLng( 12.89201, 77.58905 ); //northeast
var b_bounds = new google.maps.LatLngBounds( s_w, n_e ); //bangalorebounds
var options = {
bounds:b_bounds,
componentRestrictions: {country: "in"}
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
autocomplete.bindTo('bounds', map);
autocomplete.addListener('place_changed', function() {
//rest_of_the_code
});
请有人帮忙!!
【问题讨论】:
标签: javascript google-maps google-maps-api-3 autocomplete