Interface GeoMap
- All Superinterfaces:
Component,Component.BelongToFrame,Component.HasCaption,Component.HasDescription,Component.HasIcon,HasSubParts
- All Known Implementing Classes:
GeoMapImpl
Layers.
The map is built by superposing layers.
Initially, GeoMap has the only one layer - CanvasLayer,
which is always placed above the other layers. Canvas can be obtained by calling getCanvas() method.
Selected layer of the map is a layer which the map is focused on. Selected layer fires events, reacts on user clicks and can be modified by UI interaction (if the layer is editable). Initially, selected layer is not specified.
Attempting to pass a null value in all places where layer is expected
cause NullPointerException to be thrown
(except the cases when argument annotated as Nullable).
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents the viewing area of the map.static classAn event that is fired after click on a map.static classAn event that is fired after dragging the map.static classAn event that is fired after adding a layer on a map.static classAn event that is fired after removing a layer from a map.static classAn event that is fired after changing the map's viewing area, i.e.static classAn event that is fired after right click on a map.static classAn event that is fired after changing the map's selected layer.static classAn event that is fired after zooming the map.Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper -
Field Summary
FieldsFields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE -
Method Summary
Modifier and TypeMethodDescriptionaddClickListener(Consumer<GeoMap.ClickEvent> listener) Registers a new click listener.addDragEndListener(Consumer<GeoMap.DragEndEvent> listener) Registers a new drag end listener.voidAdds the given layer to the map.addLayerAddedListener(Consumer<GeoMap.LayerAddedEvent> listener) Registers a new layer added listener.Registers a new layer removed listener.addMoveEndListener(Consumer<GeoMap.MoveEndEvent> listener) Registers a new move end listener.addRightClickListener(Consumer<GeoMap.RightClickEvent> listener) Registers a new right click listener.Registers a new selected layer changed listener.addZoomEndListener(Consumer<GeoMap.ZoomEndEvent> listener) Registers a new zoom end listener.Returns the bounds of the map which define the viewport of the map.Returns the canvas layer of the map.org.locationtech.jts.geom.PointReturns current geographic center of the map.<T extends Layer>
TReturns a layer by its ID.<T extends Layer>
TgetLayerOrNull(String layerId) Returns a layer by its ID, ornullif the map does not contain a layer with the given ID.Returns the list of layers currently added to the map.Returns the selected layer of the map.doubleReturns current map zoom level.voidopenPopup(PopupWindow popupWindow) Opens the given popup window.voidremoveLayer(Layer layer) Removes the given layer from the map.voidselectLayer(Layer layer) Sets the selected (i.e.default voidselectLayerById(String layerId) Sets the selected (i.e.voidsetCenter(double x, double y) Sets the initial geographic center of the map.voidsetMaxZoom(int maxZoom) Sets maximum map zoom level.voidsetMinZoom(int minZoom) Sets minimum map zoom level.voidsetReadOnly(boolean readOnly) Switches map to a read-only mode.voidsetZoomLevel(double zoomLevel) Sets map zoom level.voidzoomToBounds(org.locationtech.jts.geom.Point topLeft, org.locationtech.jts.geom.Point bottomRight) Sets a map view that contains the given geographical bounds with the maximum zoom level possible.voidzoomToGeometry(org.locationtech.jts.geom.Geometry geometry) Sets a map view that contains envelope of the given geometry with the maximum zoom level possible.Methods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedCompositionMethods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrameMethods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaptionMethods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescriptionMethods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSetMethods inherited from interface io.jmix.ui.component.HasSubParts
getSubPart
-
Field Details
-
NAME
- See Also:
-
-
Method Details
-
addLayer
@StudioElementsGroup(caption="Layers", xmlElement="layers", icon="io/jmix/mapsui/icon/layers.svg", documentationURL="https://docs.jmix.io/jmix/%VERSION%/maps/layers.html") void addLayer(Layer layer) Adds the given layer to the map.Preserves an order of the layers, but tile layers (such as
TileLayerorWMSTileLayer) should be added first, otherwiseIllegalStateExceptionis to be thrown.If a layer with the same ID is already on the map, the given layer will not be added to the map and
IllegalArgumentExceptionis to be thrown.- Parameters:
layer- to be added on the map- Throws:
IllegalStateException- when attempting to add a tile layer above a vector layerIllegalArgumentException- when a layer with the same ID is already on the map
-
removeLayer
Removes the given layer from the map.- Parameters:
layer- to be removed from the map- Throws:
IllegalArgumentException- when map does not contain the specified layer
-
getLayer
Returns a layer by its ID.- Parameters:
layerId- ID of a layer- Returns:
- layer
- Throws:
IllegalArgumentException- when map does not contain a layer with the specified id
-
getLayerOrNull
Returns a layer by its ID, ornullif the map does not contain a layer with the given ID.- Parameters:
layerId- ID of a layer- Returns:
- layer
-
getLayers
Returns the list of layers currently added to the map. The resulting list preserves the order of layers (from the first added layer to the last). The Canvas layer is not included in this list. -
setCenter
void setCenter(double x, double y) Sets the initial geographic center of the map.- Parameters:
x- longitudey- latitude
-
getCenter
org.locationtech.jts.geom.Point getCenter()Returns current geographic center of the map. -
setZoomLevel
Sets map zoom level.
The default value is 15.- Parameters:
zoomLevel- of the map
-
getZoomLevel
double getZoomLevel()Returns current map zoom level. -
setMaxZoom
void setMaxZoom(int maxZoom) Sets maximum map zoom level.If not specified and at least one tile layer is on the map, the highest of their maxZoom will be used.
- Parameters:
maxZoom- maximum map zoom level
-
setMinZoom
void setMinZoom(int minZoom) Sets minimum map zoom level.If not specified and at least one tile layer is on the map, the lowest of their minZoom will be used.
- Parameters:
minZoom- minimum map zoom level
-
setReadOnly
void setReadOnly(boolean readOnly) Switches map to a read-only mode. Virtually, it means an impossibility of changing zoom, position, etc., via mouse.- Parameters:
readOnly- true/false
-
getCanvas
CanvasLayer getCanvas()Returns the canvas layer of the map.- Returns:
- Canvas layer
-
selectLayer
Sets the selected (i.e. the active) layer of the map.A
nullparameter deselects currently selected layer.- Parameters:
layer- selected layer- Throws:
IllegalArgumentException- when map does not contain the specified layer
-
selectLayerById
Sets the selected (i.e. the active) layer of the map by the given layer's ID.- Parameters:
layerId- ID of the layer- Throws:
IllegalArgumentException- when map does not contain the specified layer
-
getSelectedLayer
Returns the selected layer of the map.- Returns:
- the selected layer or
nullwhen none of the layers is selected
-
getBounds
GeoMap.Bounds getBounds()Returns the bounds of the map which define the viewport of the map. -
zoomToBounds
void zoomToBounds(org.locationtech.jts.geom.Point topLeft, org.locationtech.jts.geom.Point bottomRight) Sets a map view that contains the given geographical bounds with the maximum zoom level possible.- Parameters:
topLeft- NorthWest pointbottomRight- SouthEast point
-
zoomToGeometry
void zoomToGeometry(org.locationtech.jts.geom.Geometry geometry) Sets a map view that contains envelope of the given geometry with the maximum zoom level possible.Note: if the given geometry is point, map will be centered to this point with the current zoom level.
-
openPopup
Opens the given popup window. -
addClickListener
Registers a new click listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addRightClickListener
Registers a new right click listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addMoveEndListener
Registers a new move end listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addZoomEndListener
Registers a new zoom end listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addDragEndListener
Registers a new drag end listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addLayerAddedListener
Registers a new layer added listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addLayerRemovedListener
Registers a new layer removed listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-
addSelectedLayerChangedListener
Registers a new selected layer changed listener.- Parameters:
listener- the listener to be added- Returns:
- a registration object for removing an event listener added to a source
-