public class GeoMapImpl extends io.jmix.ui.component.impl.AbstractComponent<LMap> implements GeoMap
GeoMap.Bounds, GeoMap.ClickEvent, GeoMap.DragEndEvent, GeoMap.LayerAddedEvent, GeoMap.LayerRemovedEvent, GeoMap.MoveEndEvent, GeoMap.RightClickEvent, GeoMap.SelectedLayerChangedEvent, GeoMap.ZoomEndEvent
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
Constructor and Description |
---|
GeoMapImpl() |
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.
|
protected io.jmix.core.common.event.EventHub |
getEventHub() |
<T> java.util.Map<?,GeoObjectWrapper<T>> |
getGeoObjectWrappersMap(VectorLayer<T> layer)
Returns a map of pairs [geo-object ID: geoObjectWrapper] for geo-objects of the given vector layer.
|
<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.
|
java.lang.Object |
getSubPart(java.lang.String name) |
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.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setCenter(double x,
double y)
Sets the initial geographic center of the map.
|
void |
setMaxZoom(int maxZoom)
Set maximum map zoom level.
|
void |
setMinZoom(int minZoom)
Set minimum map zoom level.
|
void |
setReadOnly(boolean readOnly)
Switch map to a read-only mode.
|
void |
setZoomLevel(double zoomLevel)
Set 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.
|
addAttachListener, addDetachListener, addStyleName, assignDebugId, attached, detached, getAlignment, getCaption, getComponent, getComposition, getContextHelpIconClickHandler, getContextHelpText, getDebugId, getDescription, getFrame, getHeight, getHeightSizeUnit, getHtmlSanitizer, getIcon, getIconName, getIconResource, getId, getParent, getStyleName, getUiComponentProperties, getUiProperties, getWidth, getWidthSizeUnit, getXmlDescriptor, hasSubscriptions, hasValidationError, isAttached, isCaptionAsHtml, isContextHelpTextHtmlEnabled, isDescriptionAsHtml, isEnabled, isEnabledRecursive, isHtmlSanitizerEnabled, isResponsive, isVisible, isVisibleRecursive, onContextHelpIconClick, publish, removeStyleName, sanitize, setAlignment, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDebugId, setDescription, setDescriptionAsHtml, setEnabled, setFrame, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setParent, setResponsive, setStyleName, setValidationError, setVisible, setWidth, setXmlDescriptor, unsubscribe, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
selectLayerById
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
@Autowired public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in class io.jmix.ui.component.impl.AbstractComponent<LMap>
public void addLayer(Layer layer)
GeoMap
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.
public void removeLayer(Layer layer)
GeoMap
removeLayer
in interface GeoMap
layer
- to be removed from the map@Nonnull public <T extends Layer> T getLayer(java.lang.String layerId)
GeoMap
@Nullable public <T extends Layer> T getLayerOrNull(java.lang.String layerId)
GeoMap
null
if the map does not contain a layer with the given ID.getLayerOrNull
in interface GeoMap
layerId
- ID of a layerpublic java.util.List<Layer> getLayers()
GeoMap
public void setCenter(double x, double y)
GeoMap
public org.locationtech.jts.geom.Point getCenter()
GeoMap
public void setZoomLevel(double zoomLevel)
setZoomLevel
in interface GeoMap
zoomLevel
- of the mappublic double getZoomLevel()
GeoMap
getZoomLevel
in interface GeoMap
public void setMaxZoom(int maxZoom)
setMaxZoom
in interface GeoMap
maxZoom
- maximum map zoom levelpublic void setMinZoom(int minZoom)
setMinZoom
in interface GeoMap
minZoom
- minimum map zoom levelpublic void setReadOnly(boolean readOnly)
setReadOnly
in interface GeoMap
readOnly
- true/falsepublic CanvasLayer getCanvas()
GeoMap
public void selectLayer(Layer layer)
GeoMap
A null
parameter deselects currently selected layer.
selectLayer
in interface GeoMap
layer
- selected layerpublic Layer getSelectedLayer()
GeoMap
getSelectedLayer
in interface GeoMap
null
when none of the layers is selectedpublic GeoMap.Bounds getBounds()
GeoMap
public void zoomToBounds(org.locationtech.jts.geom.Point topLeft, org.locationtech.jts.geom.Point bottomRight)
GeoMap
zoomToBounds
in interface GeoMap
topLeft
- NorthWest pointbottomRight
- SouthEast pointpublic void zoomToGeometry(org.locationtech.jts.geom.Geometry geometry)
GeoMap
Note: if the given geometry is point, map will be centered to this point with the current zoom level.
zoomToGeometry
in interface GeoMap
public void openPopup(PopupWindow popupWindow)
GeoMap
public io.jmix.core.common.event.Subscription addClickListener(java.util.function.Consumer<GeoMap.ClickEvent> listener)
GeoMap
addClickListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addRightClickListener(java.util.function.Consumer<GeoMap.RightClickEvent> listener)
GeoMap
addRightClickListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addMoveEndListener(java.util.function.Consumer<GeoMap.MoveEndEvent> listener)
GeoMap
addMoveEndListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addZoomEndListener(java.util.function.Consumer<GeoMap.ZoomEndEvent> listener)
GeoMap
addZoomEndListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addDragEndListener(java.util.function.Consumer<GeoMap.DragEndEvent> listener)
GeoMap
addDragEndListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addLayerAddedListener(java.util.function.Consumer<GeoMap.LayerAddedEvent> listener)
GeoMap
addLayerAddedListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addLayerRemovedListener(java.util.function.Consumer<GeoMap.LayerRemovedEvent> listener)
GeoMap
addLayerRemovedListener
in interface GeoMap
listener
- the listener to be addedpublic io.jmix.core.common.event.Subscription addSelectedLayerChangedListener(java.util.function.Consumer<GeoMap.SelectedLayerChangedEvent> listener)
GeoMap
addSelectedLayerChangedListener
in interface GeoMap
listener
- the listener to be addedprotected io.jmix.core.common.event.EventHub getEventHub()
getEventHub
in class io.jmix.ui.component.impl.AbstractComponent<LMap>
public <T> java.util.Map<?,GeoObjectWrapper<T>> getGeoObjectWrappersMap(VectorLayer<T> layer)
In case when geo-object's geometry is null, then wrapper is also null. So perform null check before operating with a wrapper. Geo-object wrappers can be replaced with another instance after layer refresh or geometry update, so always use this map to get the relevant wrapper instance.
java.lang.IllegalArgumentException
- when map does not contain the specified layer@Nullable public java.lang.Object getSubPart(java.lang.String name)
getSubPart
in interface io.jmix.ui.component.HasSubParts