I have an website where i want to pinpoint user input to geocoords and using that adresse for something like a meeting.
The problem is that google autoplete also shows "ZIP-Codes only" or Streets without a streetno.
Is there anyway to filter the autoplete results before displaying them?
var input = /** @type {HTMLInputElement} */(
document.getElementById('pac-input'));
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(52.66805480068766, 13.7713623046875),
new google.maps.LatLng(52.32191088594773, 12.98858642578125));
var autoplete_options = {
bounds: defaultBounds,
ponentRestrictions: {country: 'de'},
types: ['geocode']
};
autoplete = new google.maps.places.Autoplete(input, autoplete_options);
google.maps.event.addListener(autoplete, 'place_changed', callServer);
My testsite to see the autoplete can be found here:
Try some inputs like 14169 (zip code) or Wilskistr (for street without housenumber).
I have an website where i want to pinpoint user input to geocoords and using that adresse for something like a meeting.
The problem is that google autoplete also shows "ZIP-Codes only" or Streets without a streetno.
Is there anyway to filter the autoplete results before displaying them?
var input = /** @type {HTMLInputElement} */(
document.getElementById('pac-input'));
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(52.66805480068766, 13.7713623046875),
new google.maps.LatLng(52.32191088594773, 12.98858642578125));
var autoplete_options = {
bounds: defaultBounds,
ponentRestrictions: {country: 'de'},
types: ['geocode']
};
autoplete = new google.maps.places.Autoplete(input, autoplete_options);
google.maps.event.addListener(autoplete, 'place_changed', callServer);
My testsite to see the autoplete can be found here: http://www.winterreifenwechsel.de/wele/termine
Try some inputs like 14169 (zip code) or Wilskistr (for street without housenumber).
Share Improve this question asked Feb 17, 2015 at 22:42 Benjamin EcksteinBenjamin Eckstein 8942 gold badges9 silver badges19 bronze badges1 Answer
Reset to default 3You can use the Place Types parameter in the URL request of the Autoplete API which accepts only the locations with the geocode. This would enable the autoplete results based on locations that have a proper lat lang and not a region.
Here is the API request for that:
https://maps.googleapis./maps/api/place/autoplete/json?input=Vict&types;=geocode&language;=fr&key;=API_KEY
For more details please refer to this Google's official doc.
EDIT
Then I would say use the Places Autoplete address form in your webapp. Here is the link for that which will restrict users to use address which you can pass as lat lng in your ,aps.