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']});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745513441a4630875.html
评论列表(0条)