Search in sources :

Example 1 with LLayers

use of org.vaadin.addon.leaflet.control.LLayers in project v-leaflet by mstahv.

the class HasControlTest method setup.

@Override
protected void setup() {
    super.setup();
    Label l = new Label("This test adds and removes overlay layers using addLayers and removeLayers.<br/> " + "A Leaflet Layers Control should never appear.", ContentMode.HTML);
    l.setWidth("500px");
    HorizontalLayout hl = new HorizontalLayout();
    CheckBox useLLayers = new CheckBox("Use LLayers control", false);
    useLLayers.addValueChangeListener((HasValue.ValueChangeListener<Boolean>) event -> {
        boolean checked = event.getValue();
        if (checked) {
            LLayers lc = new LLayers();
            map.addControl(lc);
            for (LayerWrapper lw : baseLayers) {
                lc.addBaseLayer(lw.getLayer(), lw.getDescription());
            }
            for (LayerWrapper lw : overLays) {
                lc.addOverlay(lw.getLayer(), lw.getDescription());
            }
        } else {
            map.removeControl(map.getLayersControl());
        }
    });
    hl.addComponents(l, setupBaseMaps(), setupOverlays(), useLLayers);
    content.addComponentAsFirst(hl);
}
Also used : ContentMode(com.vaadin.shared.ui.ContentMode) Arrays(java.util.Arrays) List(java.util.List) LLayers(org.vaadin.addon.leaflet.control.LLayers) HasValue(com.vaadin.data.HasValue) Type(com.vaadin.ui.Notification.Type) LMap(org.vaadin.addon.leaflet.LMap) LScale(org.vaadin.addon.leaflet.control.LScale) ValueChangeEvent(com.vaadin.data.HasValue.ValueChangeEvent) LTileLayer(org.vaadin.addon.leaflet.LTileLayer) AbstractTest(org.vaadin.addonhelpers.AbstractTest) com.vaadin.ui(com.vaadin.ui) LLayers(org.vaadin.addon.leaflet.control.LLayers) HasValue(com.vaadin.data.HasValue)

Example 2 with LLayers

use of org.vaadin.addon.leaflet.control.LLayers in project v-leaflet by mstahv.

the class LMap method removeComponent.

@Override
public void removeComponent(Component c) {
    super.removeComponent(c);
    components.remove(c);
    if (hasControl(LLayers.class)) {
        LLayers layersControl = getLayersControl();
        if (layersControl != null) {
            layersControl.removeLayer((LeafletLayer) c);
        }
    }
    // ?? is this really needed
    markAsDirty();
}
Also used : LLayers(org.vaadin.addon.leaflet.control.LLayers)

Example 3 with LLayers

use of org.vaadin.addon.leaflet.control.LLayers in project v-leaflet by mstahv.

the class LMap method setReadOnly.

@Override
public void setReadOnly(boolean readOnly) {
    boolean switchToReadOnly = readOnly && !isReadOnly();
    boolean switchToReadWrite = !readOnly && isReadOnly();
    if (switchToReadOnly) {
        readWriteState.dragging = isDraggingEnabled();
        readWriteState.touchZoom = isTouchZoomEnabled();
        readWriteState.doubleClickZoom = isDoubleZoomEnabled();
        readWriteState.boxZoom = isBoxZoomEnabled();
        readWriteState.scrollWheelZoom = isScrollWheelZoomEnabled();
        readWriteState.keyboard = isKeyboardZoomEnabled();
        readWriteState.lLayers = getLayersControl();
        readWriteState.lZoom = getZoomControl().isEnabled();
        setDraggingEnabled(!readOnly);
        setTouchZoomEnabled(!readOnly);
        setDoubleClickZoomEnabled(!readOnly);
        setBoxZoomEnabled(!readOnly);
        setScrollWheelZoomEnabled(!readOnly);
        setKeyboardEnabled(!readOnly);
        getLayersControl().remove();
        getZoomControl().setEnabled(!readOnly);
    }
    if (switchToReadWrite) {
        setDraggingEnabled(readWriteState.dragging);
        setTouchZoomEnabled(readWriteState.touchZoom);
        setDoubleClickZoomEnabled(readWriteState.doubleClickZoom);
        setBoxZoomEnabled(readWriteState.boxZoom);
        setScrollWheelZoomEnabled(readWriteState.scrollWheelZoom);
        setKeyboardEnabled(readWriteState.keyboard);
        addControl(new LLayers(readWriteState.lLayers));
        getZoomControl().setEnabled(readWriteState.lZoom);
    }
    if (readOnly != isReadOnly()) {
        getState().readOnly = readOnly;
    }
}
Also used : LLayers(org.vaadin.addon.leaflet.control.LLayers)

Example 4 with LLayers

use of org.vaadin.addon.leaflet.control.LLayers in project v-leaflet by mstahv.

the class LMap method addOverlay.

public void addOverlay(LeafletLayer overlay, String name) {
    addLayer(overlay);
    LLayers control = getLayersControl();
    if (control != null) {
        control.addOverlay(overlay, name);
    }
}
Also used : LLayers(org.vaadin.addon.leaflet.control.LLayers)

Example 5 with LLayers

use of org.vaadin.addon.leaflet.control.LLayers in project v-leaflet by mstahv.

the class LMap method addBaseLayer.

/**
 * Add a base layer with given name.
 *
 * @param baseLayer the layer to be added
 * @param name      to be used in LayerControl, null if layer should not be
 *                  displayed in the layer control
 */
public void addBaseLayer(LeafletLayer baseLayer, String name) {
    addLayer(baseLayer);
    LLayers control = getLayersControl();
    if (control != null) {
        control.addBaseLayer(baseLayer, name);
    }
}
Also used : LLayers(org.vaadin.addon.leaflet.control.LLayers)

Aggregations

LLayers (org.vaadin.addon.leaflet.control.LLayers)6 HasValue (com.vaadin.data.HasValue)1 ValueChangeEvent (com.vaadin.data.HasValue.ValueChangeEvent)1 Extension (com.vaadin.server.Extension)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 com.vaadin.ui (com.vaadin.ui)1 Type (com.vaadin.ui.Notification.Type)1 Arrays (java.util.Arrays)1 List (java.util.List)1 LMap (org.vaadin.addon.leaflet.LMap)1 LTileLayer (org.vaadin.addon.leaflet.LTileLayer)1 LScale (org.vaadin.addon.leaflet.control.LScale)1 AbstractTest (org.vaadin.addonhelpers.AbstractTest)1