Class LayersControl
java.lang.Object
org.vaadin.addons.componentfactory.leaflet.LeafletObject
org.vaadin.addons.componentfactory.leaflet.controls.LeafletControl
org.vaadin.addons.componentfactory.leaflet.controls.LayersControl
- All Implemented Interfaces:
Serializable,Identifiable,ExecutableFunctions
The layers control gives users the ability to switch between different base
layers and switch overlays on/off (check out the detailed example). Extends
Control.
The baseLayers and overlays parameters are object literals with layer names as keys and Layer objects as values.
The layer names can contain HTML, which allows you to add additional styling to the items.
The baseLayers and overlays parameters are object literals with layer names as keys and Layer objects as values.
The layer names can contain HTML, which allows you to add additional styling to the items.
- Since:
- 2020-05-29
- Version:
- 1.0
- Author:
- Gabor Kokeny Email: kokeny19@gmail.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe event types fired by the layers control.Nested classes/interfaces inherited from class org.vaadin.addons.componentfactory.leaflet.controls.LeafletControl
LeafletControl.ControlPosition -
Field Summary
Fields inherited from class org.vaadin.addons.componentfactory.leaflet.controls.LeafletControl
leafletMap -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new layers control with empty base layers and overlays and default options.LayersControl(Map<String, Layer> baseLayers) Creates a new layers control with the given base layers and default options.Creates a new layers control with the given base layers and overlays and default options.LayersControl(Map<String, Layer> baseLayers, Map<String, Layer> overlays, LayersControlOptions options) Creates a new layers control with the given base layers, overlays and options.LayersControl(LayersControlOptions options) Creates a new layers control with empty base layers and overlays and the given options. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBaseLayer(Layer layer, String name) Adds a base layer (radio button entry) with the given name to the control.voidaddOverlay(Layer layer, String name) Adds an overlay (checkbox entry) with the given name to the control.voidcollapse()Collapse the control container if expanded.voidexpand()Expand the control container if collapsed.Gets the base layers of the control keyed by their display name.Gets the overlays of the control keyed by their display name.booleanGets whether the z-index of the layers is set automatically based on their order in the control.booleanGets whether the control is initially collapsed into an icon.booleanGets whether the base layers section is hidden when there is only a single base layer.booleanGets whether the layers are sorted by name in the control.voidFired when the base layer is changed through the layer control.voidonLayerAdd(LeafletEventListener<LayersControlEvent> listener) Fired when a new layer is added to the map.voidonLayerRemove(LeafletEventListener<LayersControlEvent> listener) Fired when some layer is removed from the mapvoidonOverlayAdd(LeafletEventListener<LayersControlEvent> listener) Fired when an overlay is selected through the layer control.voidFired when an overlay is selected through the layer control.voidremoveLayer(Layer layer) Remove the given layer from the control.Methods inherited from class org.vaadin.addons.componentfactory.leaflet.controls.LeafletControl
addTo, getLeafletType, getPosition, remove, setPositionMethods inherited from class org.vaadin.addons.componentfactory.leaflet.LeafletObject
call, configureObjectMapper, executeJs, getConstructorArgumentNames, getJson, getParent, getUuid, setParentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.vaadin.addons.componentfactory.leaflet.layer.map.functions.ExecutableFunctions
call, executeJs
-
Constructor Details
-
LayersControl
public LayersControl()Creates a new layers control with empty base layers and overlays and default options. -
LayersControl
Creates a new layers control with empty base layers and overlays and the given options.- Parameters:
options- the options for the layers control
-
LayersControl
Creates a new layers control with the given base layers and default options.- Parameters:
baseLayers- the base layers keyed by their display name
-
LayersControl
Creates a new layers control with the given base layers and overlays and default options.- Parameters:
baseLayers- the base layers keyed by their display nameoverlays- the overlays keyed by their display name
-
LayersControl
public LayersControl(Map<String, Layer> baseLayers, Map<String, Layer> overlays, LayersControlOptions options) Creates a new layers control with the given base layers, overlays and options.- Parameters:
baseLayers- the base layers keyed by their display nameoverlays- the overlays keyed by their display nameoptions- the options for the layers control
-
-
Method Details
-
onBaseLayerChange
Fired when the base layer is changed through the layer control.- Parameters:
listener- the listener to call when the event occurs, notnull
-
onOverlayAdd
Fired when an overlay is selected through the layer control.- Parameters:
listener- the listener to call when the event occurs, notnull
-
onOverlayRemove
Fired when an overlay is selected through the layer control.- Parameters:
listener- the listener to call when the event occurs, notnull
-
onLayerAdd
Fired when a new layer is added to the map.- Parameters:
listener- the listener to call when the event occurs, notnull
-
onLayerRemove
Fired when some layer is removed from the map- Parameters:
listener- the listener to call when the event occurs, notnull
-
expand
public void expand()Expand the control container if collapsed. -
collapse
public void collapse()Collapse the control container if expanded. -
addBaseLayer
Adds a base layer (radio button entry) with the given name to the control.- Parameters:
layer- the layer to be added to map as a base layername- the name of the base layer
-
addOverlay
Adds an overlay (checkbox entry) with the given name to the control. *- Parameters:
layer- the layer to be added to map as an overlayname- the name of the overlay
-
removeLayer
Remove the given layer from the control.- Parameters:
layer- the layer which should be removed from theLayersControl
-
isCollapsed
public boolean isCollapsed()Gets whether the control is initially collapsed into an icon.- Returns:
trueif the control is collapsed,falseotherwise
-
isAutoZIndex
public boolean isAutoZIndex()Gets whether the z-index of the layers is set automatically based on their order in the control.- Returns:
trueif the z-index is set automatically,falseotherwise
-
isHideSingleBase
public boolean isHideSingleBase()Gets whether the base layers section is hidden when there is only a single base layer.- Returns:
trueif a single base layer is hidden,falseotherwise
-
isSortLayers
public boolean isSortLayers()Gets whether the layers are sorted by name in the control.- Returns:
trueif the layers are sorted,falseotherwise
-
getBaseLayers
Gets the base layers of the control keyed by their display name.- Returns:
- the base layers keyed by their display name
-
getOverlays
Gets the overlays of the control keyed by their display name.- Returns:
- the overlays keyed by their display name
-