Hello,
I'm building a site where the map is in "not first" vertical tab, so it is not displayed correctly when opening the tab for first time. I can't use the fixed pixel width workaround because the site should have fluid width. So I put together this few lines of jQuery, which changes the size of surrounding divs according to vertical tab pane:
var width = $(".vertical-tabs-panes").width();
$("#openlayers-map").css('width', width);
$("#openlayers-container-openlayers-map").css('width', width);
This works and the corresponding numbers on both divs are changed, but nothing happens. The map is still looking bad.
Is there a way how can I refresh just the map according the new dimensions?
I was thinking about some false window resize, because as soon as I resize the window the map refresh and is ok. But that is far over my jQuery skill.
Is this aproach even possible? Or what else can I do to get it working?
Thanks a lot for answer.
Comments
Comment #1
dshields CreditAttribution: dshields commentedI'm looking for a solution for this, too, as I have my map in a tabbed interface and it is not loading properly on the page load because it is not on the default or primary tab.
Comment #2
jamsilver CreditAttribution: jamsilver commentedNote this is not a good fix (because it wreaks a little bit too much havoc), but it does the trick for me at the moment. Others may find it useful :).
In a custom module
Then in myopenlayersoverrides.js:
Comment #3
Countzero CreditAttribution: Countzero commentedIf you're using JQuery Tabs, I posted a solution here that makes it work.