Skip to content

Map disappears when it changes position into a VerticalLayout #95

@ImMak

Description

@ImMak

Hi All,
I'm facing a strange problem:
when I've the OLMap inside a VerticalLayout not in the position 0 if
I remove a Component that is above it the latter is correctly moved up
but it becomes like invisible.

You can reproduce the problem with a VL with inside a Button and the OLMap:

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();
    final Button button = new Button("Remove me");

    button.addClickListener(new ClickListener() {
        @Override
	public void buttonClick(ClickEvent event) {
            layout.removeComponent(button);
	}
    });

    OLOSMSourceOptions opts = new OLOSMSourceOptions();
    opts.setCustomAttributions(new String []{"custom attribution"});
    opts.setShowAttributions(true);
    opts.setMaxZoom(16);

    OLOSMSource source = new OLOSMSource(opts);

    OLViewOptions opts2 = new OLViewOptions();
    opts2.setInputProjection(Projections.EPSG4326);
    OLView view = new OLView(opts2);
    view.setCenter(0, 0);
    view.setZoom(3);

    OLMap map = new OLMap();
    map.addLayer(new OLTileLayer(source));
    map.setView(view);

    layout.addComponent(button);
    layout.addComponent(map);

    getPage().setTitle("Test");
    setContent(layout);
    setSizeFull();
}

It looks like the VerticalLayout calls some methods to move up the map
and something in these methods makes it like invisible.

This is the only workaround I found:

map.setVisible(false);
getUI().push();
map.setVisible(true);
getUI().push();

but it's not really elegant and it should be called before any refresh
from the UI thread or manual push.

I hope somebody has a better idea or at least, an explanation of why this is happening.
The Vaadin version I'm using is the 7.7.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions