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);
}
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();
}
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;
}
}
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);
}
}
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);
}
}
Aggregations