Interface GeoMap
- All Superinterfaces:
Component
,Component.BelongToFrame
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,HasSubParts
- All Known Implementing Classes:
GeoMapImpl
Layer
s.
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
Modifier and TypeInterfaceDescriptionstatic interface
Represents the viewing area of the map.static class
An event that is fired after click on a map.static class
An event that is fired after dragging the map.static class
An event that is fired after adding a layer on a map.static class
An event that is fired after removing a layer from a map.static class
An event that is fired after changing the map's viewing area, i.e.static class
An event that is fired after right click on a map.static class
An event that is fired after changing the map's selected layer.static class
An 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
Fields 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.void
Adds 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.Point
Returns current geographic center of the map.Returns a function which is used to build context menu shown on right click.<T extends Layer>
TReturns a layer by its ID.<T extends Layer>
TgetLayerOrNull
(String layerId) Returns a layer by its ID, ornull
if 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.double
Returns current map zoom level.void
openPopup
(PopupWindow popupWindow) Opens the given popup window.void
removeLayer
(Layer layer) Removes the given layer from the map.void
selectLayer
(Layer layer) Sets the selected (i.e.default void
selectLayerById
(String layerId) Sets the selected (i.e.void
setCenter
(double x, double y) Sets the initial geographic center of the map.void
Sets a function which will be used to build context menu shown on right click.void
setMaxZoom
(int maxZoom) Sets maximum map zoom level.void
setMinZoom
(int minZoom) Sets minimum map zoom level.void
setReadOnly
(boolean readOnly) Switches map to a read-only mode.void
setView
(double x, double y, double zoom) Navigates to a point with provided zoom.void
setZoomLevel
(double zoomLevel) Sets map zoom level.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.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.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, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame, setFrame
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods 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
TileLayer
orWMSTileLayer
) should be added first, otherwiseIllegalStateException
is 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
IllegalArgumentException
is 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, ornull
if 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
-
setView
void setView(double x, double y, double zoom) Navigates to a point with provided zoom. Note, sets the initial geographic center of the map if not rendered.Use this method if you need to navigate to a point on the map with provided zoom. Because consequent invoking methods:
setCenter(double, double)
andsetZoomLevel(double)
can lead to wrong navigation.- Parameters:
x
- longitudey
- latitudezoom
- map zoom level
-
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
null
parameter 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
null
when 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
-
getContextMenuDelegate
Function<ContextMenuInvocationContext,ContextMenu> getContextMenuDelegate()Returns a function which is used to build context menu shown on right click. -
setContextMenuDelegate
Sets a function which will be used to build context menu shown on right click.
-