admin管理员组文章数量:1410705
is it possible to restrict the autoplete search only to cities and postal code?
This won't work:
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(cities', '(postal_code)'], ponentRestrictions: {country: "de"}});
Maybe this is right?
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(regions)'], ponentRestrictions: {country: "de"}});
Source:
But autoplete also show some results outside my restricted country, why?
Some suggestions?
Solution
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(regions)'], ponentRestrictions: {'country': "de"}});
is it possible to restrict the autoplete search only to cities and postal code?
This won't work:
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(cities', '(postal_code)'], ponentRestrictions: {country: "de"}});
Maybe this is right?
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(regions)'], ponentRestrictions: {country: "de"}});
Source: https://developers.google./places/supported_types
But autoplete also show some results outside my restricted country, why?
Some suggestions?
Solution
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(regions)'], ponentRestrictions: {'country': "de"}});
Share
edited Jul 25, 2018 at 8:44
yfain
asked Jul 25, 2018 at 6:33
yfainyfain
4967 silver badges25 bronze badges
1 Answer
Reset to default 4The code below is the correct answer to my question.
autoplete = new google.maps.places.Autoplete(
/** @type {!HTMLInputElement} */(document.getElementById('autoplete')),
{types: ['(regions)'], ponentRestrictions: {'country': "de"}});
本文标签: javascriptGoogle Maps Autocompleteonly cities and postal codeStack Overflow
版权声明:本文标题:javascript - Google Maps Autocomplete - only cities and postal code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745043558a2639224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论