admin管理员组文章数量:1328387
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.
本文标签: javascriptGoogle Maps autocomplete only Streets with NumberStack Overflow
版权声明:本文标题:javascript - Google Maps autocomplete only Streets with Number - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742217181a2434785.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论