我已经看过一些类似的帖子,但似乎无法在我的网站中加入任何内容。我正试图“限制”谷歌地图自动填充只到英国,并从完整地址删除国家 - 例如,如果用户搜索伦敦而不是输入是英国伦敦,我只想实现伦敦。
这是我目前的剧本:
jQuery(document).ready(function () {
cs_fe_search_map();
cs_load_location_ajax();
if (jQuery("#fe_map0 #cs-map-location-fe-id").hasClass("gllpMap")) {
var vals;
cs_map_location_load('0');
if (vals)
cs_search_map(vals);
}
});
function cs_fe_search_map() {
var vals;
vals = jQuery('#fe_map0 #loc_address').val();
jQuery('#fe_map0 .gllpSearchField_fe').val(vals);
}
(function ($) {
$(function () {
autocomplete = new google.maps.places.Autocomplete(document.getElementById('loc_address'));
});
})(jQuery);
jQuery(document).ready(function () {
var $ = jQuery;
jQuery("[id^=map_canvas]").css("pointer-events", "none");
jQuery("[id^=cs-map-location]").css("pointer-events", "none");
// on leave handle
var onMapMouseleaveHandler = function (event) {
var that = jQuery(this);
that.on('click', onMapClickHandler);
that.off('mouseleave', onMapMouseleaveHandler);
jQuery("[id^=map_canvas]").css("pointer-events", "none");
jQuery("[id^=cs-map-location]").css("pointer-events", "none");
}
// on click handle
var onMapClickHandler = function (event) {
var that = jQuery(this);
// Disable the click handler until the user leaves the map area
that.off('click', onMapClickHandler);
// Enable scrolling zoom
that.find('[id^=map_canvas]').css("pointer-events", "auto");
that.find('[id^=cs-map-location]').css("pointer-events", "auto");
// Handle the mouse leave event
that.on('mouseleave', onMapMouseleaveHandler);
}
// Enable map zooming with mouse scroll when the user clicks the map
jQuery('.cs-map-section').on('click', onMapClickHandler);
// new addition
});
非常感谢任何有关实施某些内容的帮助,因为我真的在努力实现这一目标! :d