mstahv / v-leaflet

Leaflet add-on for Vaadin
Other
43 stars 38 forks source link

ZoomToContent does not work when LMap is placed in VerticalSplitPanel #193

Open TorstenBMR opened 6 years ago

TorstenBMR commented 6 years ago

this one is weird: I take a LMap, add 2 Markers, zoom it to its content. The map is zoomed correctly, if attached to any layout (e.g. VerticalLayout), but not, if attached to a VerticalSplitPanel - see screenshot (left is VerticalSplitPanel, right is VerticalLayout).

auswahl_001

This is the code:

{
HorizontalLayout hl = new MHorizontalLayout().withFullWidth().withFullHeight();
    {
      Label label = new MLabel("This one doesn't zoom");
      VerticalSplitPanel vsp1 = new VerticalSplitPanel(label, createMap());
      vsp1.setHeight("100%");
      hl.addComponent(vsp1);
    }
    {
      Label label = new MLabel("This one works fine");
      VerticalLayout vsp2 = new MVerticalLayout(label, createMap()).withFullHeight();
      hl.addComponent(vsp2);
    }
    Window w = new Window("Maps", hl);
    w.setWidth("1000px");
    w.setHeight("800px");
    w.center();
    UI.getCurrent().addWindow(w);
  }

 private Component createMap()
  {
    map = new LMap();
    map.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
    map.addComponent(new LMarker(50d,10d));
    map.addComponent(new LMarker(50.1d,10.1d));
    map.setSizeFull();
    map.zoomToContent();  
    return map;
  }

`` I'm using Vaadin 7.7.14 and VLeaflet 1.06.