I'm using fieldgroup module to tidy up my input forms. It seems I can't place the map widget into a closed tab, since then the map only displays in a small fraction of the allocated area.

https://skitch.com/nikkenheimer/fjkfg/create-trip-horisontrejser

Placing it in open tabs works.

I'm using Chrome and FF on OSX. The theme is currently still core Bartik.

Comments

phayes’s picture

Project: Geofield » Openlayers
Version: 7.x-1.x-dev » 7.x-2.x-dev

This is an issue with open-layers...

Regrettably I think this is *actually* an issue with the google-maps API that is used to draw the base-layer you are using.

I would suggesting googling for the openlayers JS library and see how it deals with google maps layers and see if other people have seen this issue

NicolasH’s picture

Yeah, ok....makes sense. Thanks for the clarification.

zzolo’s picture

Hey @NicolasH, were you able to find a way around this. Its a tough one.

zzolo’s picture

Title: OpenLayers input widget does not work properly when placed in vertical/horizontal tabs » Deal with OL maps not being able to be hidden on pageload.
Category: bug » task

Related issue: #1025708: Open Layers and Quicktabs (with ajax): TypeError: this.center is null

This is mostly a limitation of the OL library not being able to initialize maps on page load. We can either workaround this in the module, or focus on fixing upstream. The latter is better but requires specific expertise and time.

Basic search suggests using map.updateSize()?

nod_’s picture

Actually i think it's an issue with verticaltabs. I have a custom form with a few fieldsets hidden in one of them is a OL map, no problem with it. Can someone post a way to replicate this ? (and it's working fine for the center map in admin form too)

Is this just with gmap ?
thansk.

castawaybcn’s picture

Subscribing.
I came here from #1168440: google maps layer not properly displayed - thanks zzolo- I have a similar issue but with 6.x and the map (google only) is displayed in a colorbox

NicolasH’s picture

@zzolo, no, having the map in an initially closed tab was a nice-to-have, not a requirement, so I just placed it somewhere else. Thanks for looking into it, though.

zzolo’s picture

So, this should in theory be working fine. The OL UI module uses vertical tabs and has a map in one.

If this is still a problem, the only solution we can try to do is create a behavior for fieldsets that runs map.updateSize() when it it opens up, but otherwise, people will have to manage this themselves.

RuiMendes’s picture

I'm having the same problem with views accordion:
http://www.bichodepessego.com/fpsk_new/en/user/20

did anyone find a solution for this?

Thanks.

zzolo’s picture

Status: Active » Closed (works as designed)

This should work if the element is rendered on load (not hidden with display none). And if that doesn't work, you'll have to use map.updateSize() in some way.

Countzero’s picture

Issue summary: View changes

Just for people who are struggling with this, here is some sample code I finally used to make it work.

This works for a map embeded in a JQuery Tab :

(function($) {
Drupal.behaviors.nmrz =  { // Whatever fits your namespace
  attach: function (context, settings) {
    $('#tabs').on('tabsactivate', function(event, ui) { // Id of the DIV containing the tabs
      if (ui.newPanel.selector == "#tabs-2") { // Id of the tab containing the OL stuff
        var mapObj = $('#openlayers-map').data('openlayers'); // Id of the DIV containing the map itself
        mapObj.openlayers.div.style.width = '862px';  // This has to be a different size from the original one ...
        mapObj.openlayers.updateSize(); /// .. otherwise this will do nothing.
      }
    });
  }  
};
})(jQuery);

Hope it can help and thanks for the tips contained in this thread.

Pol’s picture

For which version of Openlayers ?

Countzero’s picture

OL 2-dev, the one listed for this issue.

Pol’s picture

Ok.

namwebs’s picture

@Countzero #11 - I have the same requirement; can you please elaborate on where this code needs to go?

Countzero’s picture

Somewhere in a custom module's js file, as per https://www.drupal.org/node/756722.

namwebs’s picture

Thanks, I will give it a go.

Update - great, I got it working.

:-)