Image of errors occuring in my website 我想将仅限于城市的Google自动填充建议限制为英国。 但每当我试图将它过滤到英国。即使不是来自全世界或英国,我也没有任何建议。它是一个内置于主题的wordpress网站搜索。 我在我的主题目录中获得了该代码。如果有人可以帮助我对该代码进行适当的更改,以获得非常感谢的正确结果。
function autofilllocation()
{
$(".location-autocomplete").each(function(){
var element = $(this).get(0);
var autocomplete = new google.maps.places.Autocomplete(
element ,
{ types: ['geocode'] }
);
if($(element).hasClass('filter-location')) {
google.maps.event.addListener(autocomplete, 'place_changed', function() {
$( document.body ).trigger( 'ajax_filter_search' );
});
}
});
}
帮帮我PLZ 这是一张错误图片。
答案 0 :(得分:2)
您应该按国家/地区应用组件限制。请查看文档中的自动填充选项对象:
http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/
在您的代码中,您可以这样做:
var autocomplete = new google.maps.places.Autocomplete(
element ,
{
types: ['geocode'],
componentRestrictions: {
country: 'GB'
}
}
);
关于jsbin的例子:https://developers.google.com/maps/documentation/javascript/3.exp/reference#AutocompleteOptions