Moving openlayers inside a tabs (CCK Fieldgroup Tabs) i get "Error during map rendering: TypeError: size is null" thrown by Drupal.behaviors.openlayers (openlayers.js), manually setting map.width and map.height at line 64/65 I have the map displayed correctly.
I'm trying to move this markup in theme function as suggested in the comment at line 63 to see if this gets solved

Comments

tmcw’s picture

Setting the width and height of the map preset isn't working? Maps with width: auto; are known to not work inside divs with display: none; because the browser doesn't actually calculate width - it returns NaN.

marco.giaco’s picture

You're right, setting map width into presets to a fixed value or to 100%, solves this problem

strk’s picture

What are the drawbacks of using 100% by default rather than auto ?

tmcw’s picture

From http://archivist.incutio.com/viewlist/css-discuss/64711

100% means fully 100% of the window. Auto means
( 100% of the window - borders - margin - left and right positioning
). If the borders are both 10%, auto will compute to 80%. It is more
robust for standards compliant browsers, since you are basically
telling it to fill whatever is left.

tmcw’s picture

Status: Active » Closed (won't fix)

Marking as won't fix - this is an upstream bug.

henrijs.seso’s picture

Status: Closed (won't fix) » Active

Same error message in Vertical Tabs. When width and height is set in Presets, error is gone but still NO map. Maybe it is worth looking into, since Vertical Tabs are in Core in D7?

henrijs.seso’s picture

Status: Active » Closed (won't fix)

Sorry, something else is wrong, no map outside VT too.

henrijs.seso’s picture

Status: Closed (won't fix) » Active

I have to open this again, since problem still exists in some form and will get worse with D7. Problem is that maps (js) behaves strange when rendered in hidden div. Some maps are simply off center and sprigs in place as soon as map is moved (mapnik), others are way off center and kind of cropped (gmaps) and some are even around the globe off (default center for US I guess) and when moved, map is not moving but feature layer is. Zooming with zoom bar makes object in featured layer move diagonally.

tmcw’s picture

As I stated before (but didn't give enough detail), this is an upstream problem: so, despite the fact that this is a problem with panels and D7, it's not a problem that can be fixed within the scope of this module. If you want to submit a bug report at openlayers.org, go for it - and this may in fact be fixed by OpenLayers 2.10, although I suspect that it isn't entirely fixable, since it's a browser / DOM restriction that hidden divs have NaN width and height.

tmcw’s picture

Status: Active » Closed (won't fix)

Marking again as won't fix, because this is again an unstream bug. Feel free to post an issue on openlayers.org, but this isn't going to be fixed in this module because it isn't a problem created by this module.

joshuabud’s picture

Has anyone been able to fix the map load issue? I experience the same problem with regards to no map showing when width is set to auto, but with a defined pixel width it seems to allow the map to show however upon first load it's not displayed properly. With a simple drag or zoom it snaps into place and looks as expected.

Looking for some direction.

sjs’s picture

I got this fixed by using the "off-left" workaround documented here:
http://jqueryui.com/demos/tabs/

Replace
.quicktabs-hide {
display: none;
}
with:
.quicktabs-hide {
position: absolute;
left: -10000px;
}

in quicktabs/css/quicktabs.css

sstose’s picture

left: -10000 didn't work for me (mapnik), but top: -10000 did work. With map preset at 'auto'.

cheers, thanks for help.

jglynn’s picture

It's not immediately clear from reading the above comments, but if you go to your OpenLayers -> Maps page, then edit your map, you can change the width setting from 'auto' to a fixed pixel dimension. This will fix the rendering in tabs.

dude74’s picture

Issue summary: View changes

Thks jglynn !!!

Your tip is fantastic to solve quicktabs and openlayers compatibility !

ron williams’s picture

I want to extend https://www.drupal.org/node/834660#comment-4444274 to resolve an issue I had with panels in conjunction with quicktabs and openlayers.

In my case after hunting for the fix, I was able to figured it out using the following:
/* Fixes issue with map */
.quicktabs-hide {
position: absolute;
top: -10000px;
display: block;
left: 0;
right: 0;
}

dr_thomas64’s picture

That sort of works for me - I can use auto to set the map width again but only if I select "Yes: Load only the first tab on page view" in the Quicktab settings. Otherwise I get no map at all. Still - at least I can now get my tabs to behave consistently. Many thanks.