@StudioComponent(caption="GeoMap",
xmlElement="geoMap",
xmlns="http://jmix.io/schema/maps/ui",
xmlnsAlias="maps",
category="Maps",
icon="io/jmix/mapsui/icon/geoMap.svg",
canvasIcon="io/jmix/mapsui/icon/geoMap_canvas.svg",
canvasIconSize=LARGE,
documentationURL="https://docs.jmix.io/jmix/%VERSION%/maps/maps-ui.html")
public interface GeoMap
extends io.jmix.ui.component.Component, io.jmix.ui.component.Component.BelongToFrame, io.jmix.ui.component.Component.HasIcon, io.jmix.ui.component.Component.HasCaption, io.jmix.ui.component.HasSubParts
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
).
Modifier and Type | Interface and Description |
---|---|
static interface |
GeoMap.Bounds
Represents the viewing area of the map.
|
static class |
GeoMap.ClickEvent
An event that is fired after click on a map.
|
static class |
GeoMap.DragEndEvent
An event that is fired after dragging the map.
|
static class |
GeoMap.LayerAddedEvent
An event that is fired after adding a layer on a map.
|
static class |
GeoMap.LayerRemovedEvent
An event that is fired after removing a layer from a map.
|
static class |
GeoMap.MoveEndEvent
An event that is fired after changing the map's viewing area, i.e.
|
static class |
GeoMap.RightClickEvent
An event that is fired after right click on a map.
|
static class |
GeoMap.SelectedLayerChangedEvent
An event that is fired after changing the map's selected layer.
|
static class |
GeoMap.ZoomEndEvent
An event that is fired after zooming the map.
|
io.jmix.ui.component.Component.Alignment, io.jmix.ui.component.Component.BelongToFrame, io.jmix.ui.component.Component.Disposable, io.jmix.ui.component.Component.Editable, io.jmix.ui.component.Component.Focusable, io.jmix.ui.component.Component.HasCaption, io.jmix.ui.component.Component.HasDescription, io.jmix.ui.component.Component.HasIcon, io.jmix.ui.component.Component.HasXmlDescriptor, io.jmix.ui.component.Component.Wrapper
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
Modifier and Type | Method and Description |
---|---|
io.jmix.core.common.event.Subscription |
addClickListener(java.util.function.Consumer<GeoMap.ClickEvent> listener)
Registers a new click listener.
|
io.jmix.core.common.event.Subscription |
addDragEndListener(java.util.function.Consumer<GeoMap.DragEndEvent> listener)
Registers a new drag end listener.
|
void |
addLayer(Layer layer)
Adds the given layer to the map.
|
io.jmix.core.common.event.Subscription |
addLayerAddedListener(java.util.function.Consumer<GeoMap.LayerAddedEvent> listener)
Registers a new layer added listener.
|
io.jmix.core.common.event.Subscription |
addLayerRemovedListener(java.util.function.Consumer<GeoMap.LayerRemovedEvent> listener)
Registers a new layer removed listener.
|
io.jmix.core.common.event.Subscription |
addMoveEndListener(java.util.function.Consumer<GeoMap.MoveEndEvent> listener)
Registers a new move end listener.
|
io.jmix.core.common.event.Subscription |
addRightClickListener(java.util.function.Consumer<GeoMap.RightClickEvent> listener)
Registers a new right click listener.
|
io.jmix.core.common.event.Subscription |
addSelectedLayerChangedListener(java.util.function.Consumer<GeoMap.SelectedLayerChangedEvent> listener)
Registers a new selected layer changed listener.
|
io.jmix.core.common.event.Subscription |
addZoomEndListener(java.util.function.Consumer<GeoMap.ZoomEndEvent> listener)
Registers a new zoom end listener.
|
GeoMap.Bounds |
getBounds()
Returns the bounds of the map which define the viewport of the map.
|
CanvasLayer |
getCanvas()
Returns the canvas layer of the map.
|
org.locationtech.jts.geom.Point |
getCenter()
Returns current geographic center of the map.
|
<T extends Layer> |
getLayer(java.lang.String layerId)
Returns a layer by its ID.
|
<T extends Layer> |
getLayerOrNull(java.lang.String layerId)
Returns a layer by its ID, or
null if the map does not contain a layer with the given ID. |
java.util.List<Layer> |
getLayers()
Returns the list of layers currently added to the map.
|
Layer |
getSelectedLayer()
Returns the selected layer of the map.
|
double |
getZoomLevel()
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(java.lang.String layerId)
Sets the selected (i.e.
|
void |
setCenter(double x,
double y)
Sets the initial geographic center of the map.
|
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 |
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.
|
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
getIcon, setIcon, setIconFromSet
static final java.lang.String NAME
@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)
Preserves an order of the layers, but tile layers
(such as TileLayer
or WMSTileLayer
) should be added first, otherwise
IllegalStateException
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.
layer
- to be added on the mapjava.lang.IllegalStateException
- when attempting to add a tile layer above a vector layerjava.lang.IllegalArgumentException
- when a layer with the same ID is already on the mapvoid removeLayer(Layer layer)
layer
- to be removed from the mapjava.lang.IllegalArgumentException
- when map does not contain the specified layer@Nonnull <T extends Layer> T getLayer(java.lang.String layerId)
layerId
- ID of a layerjava.lang.IllegalArgumentException
- when map does not contain a layer with the specified id@Nullable <T extends Layer> T getLayerOrNull(java.lang.String layerId)
null
if the map does not contain a layer with the given ID.layerId
- ID of a layerjava.util.List<Layer> getLayers()
void setCenter(double x, double y)
x
- longitudey
- latitudeorg.locationtech.jts.geom.Point getCenter()
@StudioProperty(name="zoom") void setZoomLevel(double zoomLevel)
zoomLevel
- of the mapdouble getZoomLevel()
void setMaxZoom(int maxZoom)
If not specified and at least one tile layer is on the map, the highest of their maxZoom will be used.
maxZoom
- maximum map zoom levelvoid setMinZoom(int minZoom)
If not specified and at least one tile layer is on the map, the lowest of their minZoom will be used.
minZoom
- minimum map zoom levelvoid setReadOnly(boolean readOnly)
readOnly
- true/falseCanvasLayer getCanvas()
void selectLayer(@Nullable Layer layer)
A null
parameter deselects currently selected layer.
layer
- selected layerjava.lang.IllegalArgumentException
- when map does not contain the specified layerdefault void selectLayerById(java.lang.String layerId)
layerId
- ID of the layerjava.lang.IllegalArgumentException
- when map does not contain the specified layer@Nullable Layer getSelectedLayer()
null
when none of the layers is selectedGeoMap.Bounds getBounds()
void zoomToBounds(org.locationtech.jts.geom.Point topLeft, org.locationtech.jts.geom.Point bottomRight)
topLeft
- NorthWest pointbottomRight
- SouthEast pointvoid zoomToGeometry(org.locationtech.jts.geom.Geometry geometry)
Note: if the given geometry is point, map will be centered to this point with the current zoom level.
void openPopup(PopupWindow popupWindow)
io.jmix.core.common.event.Subscription addClickListener(java.util.function.Consumer<GeoMap.ClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addRightClickListener(java.util.function.Consumer<GeoMap.RightClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addMoveEndListener(java.util.function.Consumer<GeoMap.MoveEndEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addZoomEndListener(java.util.function.Consumer<GeoMap.ZoomEndEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addDragEndListener(java.util.function.Consumer<GeoMap.DragEndEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addLayerAddedListener(java.util.function.Consumer<GeoMap.LayerAddedEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addLayerRemovedListener(java.util.function.Consumer<GeoMap.LayerRemovedEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addSelectedLayerChangedListener(java.util.function.Consumer<GeoMap.SelectedLayerChangedEvent> listener)
listener
- the listener to be added