admin管理员组文章数量:1023782
Given the bounds of a specific city in the form of a google.maps.LatLngBounds
type variable, I want to get street addresses from that specific area as results of the autoplete feature.
I read that using bounds in Google Maps API gives only approximate results and that would work for me. Problem is: at the moment results are not even close to the specified area.
<input type="text" class="event_form_input" id="event_address" name="event_address" placeholder="Address" value="">
var address_input = document.getElementById('event_address');
var address_autoplete = new google.maps.places.Autoplete(address_input,{bounds: event_city_bounds, types: ['geocode']});
address_autoplete.addListener('place_changed', function(){
var event_address=address_autoplete.getPlace();
})
What I am getting are both city names and addresses with no restrictions at all. I already checked the variable event_city_bounds
and it always contains the correct bounds of any city I previously select (from another input menu).
Hope someone can help.
Given the bounds of a specific city in the form of a google.maps.LatLngBounds
type variable, I want to get street addresses from that specific area as results of the autoplete feature.
I read that using bounds in Google Maps API gives only approximate results and that would work for me. Problem is: at the moment results are not even close to the specified area.
<input type="text" class="event_form_input" id="event_address" name="event_address" placeholder="Address" value="">
var address_input = document.getElementById('event_address');
var address_autoplete = new google.maps.places.Autoplete(address_input,{bounds: event_city_bounds, types: ['geocode']});
address_autoplete.addListener('place_changed', function(){
var event_address=address_autoplete.getPlace();
})
What I am getting are both city names and addresses with no restrictions at all. I already checked the variable event_city_bounds
and it always contains the correct bounds of any city I previously select (from another input menu).
Hope someone can help.
1 Answer
Reset to default 3Types supported in place autoplete requests:
address instructs the Place Autoplete service to return only geocoding results with a precise address. Generally, you use this request when you know the user will be looking for a fully specified address.
So you can try something like this
var address_autoplete = new google.maps.places.Autoplete(address_input,{bounds: event_city_bounds, types: ['address']});
Given the bounds of a specific city in the form of a google.maps.LatLngBounds
type variable, I want to get street addresses from that specific area as results of the autoplete feature.
I read that using bounds in Google Maps API gives only approximate results and that would work for me. Problem is: at the moment results are not even close to the specified area.
<input type="text" class="event_form_input" id="event_address" name="event_address" placeholder="Address" value="">
var address_input = document.getElementById('event_address');
var address_autoplete = new google.maps.places.Autoplete(address_input,{bounds: event_city_bounds, types: ['geocode']});
address_autoplete.addListener('place_changed', function(){
var event_address=address_autoplete.getPlace();
})
What I am getting are both city names and addresses with no restrictions at all. I already checked the variable event_city_bounds
and it always contains the correct bounds of any city I previously select (from another input menu).
Hope someone can help.
Given the bounds of a specific city in the form of a google.maps.LatLngBounds
type variable, I want to get street addresses from that specific area as results of the autoplete feature.
I read that using bounds in Google Maps API gives only approximate results and that would work for me. Problem is: at the moment results are not even close to the specified area.
<input type="text" class="event_form_input" id="event_address" name="event_address" placeholder="Address" value="">
var address_input = document.getElementById('event_address');
var address_autoplete = new google.maps.places.Autoplete(address_input,{bounds: event_city_bounds, types: ['geocode']});
address_autoplete.addListener('place_changed', function(){
var event_address=address_autoplete.getPlace();
})
What I am getting are both city names and addresses with no restrictions at all. I already checked the variable event_city_bounds
and it always contains the correct bounds of any city I previously select (from another input menu).
Hope someone can help.
1 Answer
Reset to default 3Types supported in place autoplete requests:
address instructs the Place Autoplete service to return only geocoding results with a precise address. Generally, you use this request when you know the user will be looking for a fully specified address.
So you can try something like this
var address_autoplete = new google.maps.places.Autoplete(address_input,{bounds: event_city_bounds, types: ['address']});
本文标签: javascriptGoogle Maps API How to get street addresses only as results of AutocompleteStack Overflow
版权声明:本文标题:javascript - Google Maps API: How to get street addresses only as results of Autocomplete - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745513438a2153930.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论