Openlayers inside jquery ui tabs

2020-06-27 01:27发布

问题:

I want to use Openlayers inside jquery ui tabs but I get error: "size is null"!

回答1:

Had the same problem. It's explained at jquery tabs and problems-with-google-maps-api-v3-jquery-ui-tabs.

What I did: in my jquery-ui-1.7.1.custom.css (most recent is 1.8.2) find the line:

.ui-tabs .ui-tabs-hide { display: none !important; }

and change it to:

.ui-tabs .ui-tabs-hide { position: absolute;
        left: -10000px; }


回答2:

What's i have done :

// Get hidden tabs content
var $cache = $(".ui-tabs-hide");

// Make them visible
$cache.removeClass("ui-tabs-hide");

// Initialize your map here
...

// Re-hide the tabs content
$cache.addClass("ui-tabs-hide");