更新时间:2023-02-14 12:34:17
#map
元素必须在页面中可见...
The #map
element must be visible in the page...
所以需要把初始化代码放在slideToggle
的回调中.
So you need to put the initialization code in the callback to the slideToggle
.
$(document).ready(function() {
//Hide (Collapse) the toggle containers on load
$(".toggle_container").hide();
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$("h9.trigger").click(function() {
$(this).toggleClass("active").next().slideToggle("slow", function() {
if ($(this).is(':visible')) {
map = InitMap(null, 'map', centerCoord, true); // initialize the map on default location
}
});
return false; //Prevent the browser jump to the link anchor
});
handle_clicks(); // click events handling by jQuery
});