Class GeoMap
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasSize
,com.vaadin.flow.component.HasStyle
,Serializable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
Layer
s.
The map is built by superposing layers. Initially, map does not have layers.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected elemental.json.JsonValue
protected Collection<ProjectionRegistration>
protected CRS
protected elemental.json.JsonValue
Fields inherited from class io.jmix.mapsflowui.kit.component.JmixMap
featureClickDomRegistration, featureDoubleClickDomRegistration, featureSingleClickDomRegistration, mapClickDomRegistration, mapDoubleClickDomRegistration, mapSingleClickDomRegistration, mapZoomChangedDomRegistration, options, rendered, serializer, synchronizeMapExecution
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
addClickListener
(com.vaadin.flow.component.ComponentEventListener<MapClickEvent> listener) Adds map click listener.com.vaadin.flow.shared.Registration
addDoubleClickListener
(com.vaadin.flow.component.ComponentEventListener<MapDoubleClickEvent> listener) Adds map double click listener.void
Adds layer to the map.com.vaadin.flow.shared.Registration
addMoveEndListener
(com.vaadin.flow.component.ComponentEventListener<MapMoveEndEvent> listener) Adds map move end listener.com.vaadin.flow.shared.Registration
addSingleClickListener
(com.vaadin.flow.component.ComponentEventListener<MapSingleClickEvent> listener) Adds map single click listener.com.vaadin.flow.shared.Registration
addZoomChangedListener
(com.vaadin.flow.component.ComponentEventListener<MapZoomChangedEvent> listener) Adds map zoom changed listener.void
protected void
protected MapOptions
protected JmixMapSerializer
protected void
fireFeatureClickEvent
(EventBus eventBus, AbstractFeatureClickDomEvent event, Feature feature) protected void
fireMapClickEvent
(MapClickDomEvent domEvent) protected void
protected void
fireMapMoveEndEvent
(MapMoveEndDomEvent domEvent) protected void
protected void
fireMapZoomChangeEvent
(MapZoomChangedDomEvent domEvent) protected void
fireSourceFeatureClickEvent
(EventBus eventBus, AbstractFeatureClickDomEvent event, Feature feature, AbstractFeatureSource source) void
fit
(FitOptions options) Fits the given geometry or extent based on the given map size and border and provided options.org.locationtech.jts.geom.Coordinate
Gets coordinates of the geographic center of the map's visible area.<L extends Layer<?>>
LgetLayerOrNull
(String layerId) Returns a layer by its ID ornull
if the map does not contain a layer with the provided ID.protected void
onDetach
(com.vaadin.flow.component.DetachEvent detachEvent) protected void
protected void
protected void
protected void
protected void
onMapZoomChangedEvent
(MapZoomChangedDomEvent domEvent) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setCenter
(org.locationtech.jts.geom.Coordinate center) Sets the geographic center of the map's visible area.void
setMapView
(MapView view) Sets map view.void
setProjection
(CRS projection) Sets the projection for coordinates supplied from and returned by API methods.void
zoomToExtent
(org.locationtech.jts.geom.Coordinate bottomLeft, org.locationtech.jts.geom.Coordinate topRight) Sets a map's visible area that contains the given geographical bounds with the maximum zoom level possible.void
zoomToFeature
(Feature feature) Sets a map's visible area that contains envelope of the geometry from given feature.void
zoomToGeometry
(org.locationtech.jts.geom.Geometry geometry) Sets a map's visible area that contains envelope of the given geometry with the maximum zoom level possible.Methods inherited from class io.jmix.mapsflowui.kit.component.JmixMap
attachFeatureClickDomEventListeners, attachMapClickDomEventListener, attachMapDoubleClickDomEventListener, attachMapMoveEndListener, attachMapOptionsChangeListener, attachMapSingleClickDomEventListener, attachMapZoomChangedListener, findFeatureBySyncId, findLayerBySyncId, getLayer, getLayers, getZoom, onAttach, onFeatureClickEvent, onMapOptionsChange, performUpdateMap, removeLayer, requestUpdateMap, setZoom, zoomToExtent
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext -
projections
-
userProjection
-
zoomToJson
protected elemental.json.JsonValue zoomToJson -
fitJson
protected elemental.json.JsonValue fitJson
-
-
Constructor Details
-
GeoMap
public GeoMap()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
autowireDependencies
protected void autowireDependencies() -
addLayer
Adds layer to the map. -
getLayerOrNull
Returns a layer by its ID ornull
if the map does not contain a layer with the provided ID.- Overrides:
getLayerOrNull
in classJmixMap
- Type Parameters:
L
- layer type- Parameters:
layerId
- ID of a layer- Returns:
- layer
-
getMapView
- Overrides:
getMapView
in classJmixMap
- Returns:
- map view
-
setMapView
Sets map view. It replaces previous default map view. To change zoom or center coordinate, useJmixMap.getMapView()
, for instance:map.getMapView().setZoom(10);
- Overrides:
setMapView
in classJmixMap
- Parameters:
view
- map view to set- See Also:
-
setProjection
Sets the projection for coordinates supplied from and returned by API methods.Note, the projection will be used for all maps on the page.
- Parameters:
projection
- projection to set
-
getCenter
public org.locationtech.jts.geom.Coordinate getCenter()Gets coordinates of the geographic center of the map's visible area.Delegates to the map's view. See
getMapView()
.- Returns:
- current center of the map's visible area
-
setCenter
public void setCenter(org.locationtech.jts.geom.Coordinate center) Sets the geographic center of the map's visible area. Coordinates must be specified in the map projection, which isEPSG:4326
.If the map projection has been changed using
setProjection(CRS)
, then coordinates must be specified in that projection.Note that the map projection is a different concept than the view projection set in the map's
GeoMapView
. The view projection affects how map data is interpreted and rendered, while the map projection defines the coordinate system that all coordinates passed to, or returned from the public API must be in.Delegates to the map's view. See
getMapView()
.- Parameters:
center
- new center of the visible area
-
zoomToExtent
public void zoomToExtent(org.locationtech.jts.geom.Coordinate bottomLeft, org.locationtech.jts.geom.Coordinate topRight) Sets a map's visible area that contains the given geographical bounds with the maximum zoom level possible.To zoom to an extent more advanced way, use
fit(FitOptions)
.- Parameters:
bottomLeft
- bottom left point coordinates of visible area (SouthWest)topRight
- top right point coordinates of visible area (NorthEast)
-
zoomToFeature
Sets a map's visible area that contains envelope of the geometry from given feature.This is the convenience method that delegates to
zoomToGeometry(Geometry)
.- Parameters:
feature
- feature from which geometry will be zoomed to
-
zoomToGeometry
public void zoomToGeometry(org.locationtech.jts.geom.Geometry geometry) Sets a map's visible area that contains envelope of the given geometry with the maximum zoom level possible.To zoom to a geometry more advanced way, use
fit(FitOptions)
.Note: if the given geometry is a point, map will be centered to this point with the current zoom level.
- Parameters:
geometry
- geometry to zoom
-
fit
Fits the given geometry or extent based on the given map size and border and provided options. For instance, if it is needed to specify maximum zoom level and animation we can do the following:map.fit(new FitOptions(feature) .withMaxZoom(9.0) .withDuration(1500) .withEasing(Easing.LINEAR));
For more details see: View#fit() docs
- Parameters:
options
- options that configure zooming to an extent or geometry
-
addClickListener
public com.vaadin.flow.shared.Registration addClickListener(com.vaadin.flow.component.ComponentEventListener<MapClickEvent> listener) Adds map click listener. Note, if the user makes double click on a map, theMapClickEvent
will be fired twice.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener
-
addSingleClickListener
public com.vaadin.flow.shared.Registration addSingleClickListener(com.vaadin.flow.component.ComponentEventListener<MapSingleClickEvent> listener) Adds map single click listener. Single click means that an event won't be fired if the user makes double click.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener
-
addDoubleClickListener
public com.vaadin.flow.shared.Registration addDoubleClickListener(com.vaadin.flow.component.ComponentEventListener<MapDoubleClickEvent> listener) Adds map double click listener.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener
-
addZoomChangedListener
public com.vaadin.flow.shared.Registration addZoomChangedListener(com.vaadin.flow.component.ComponentEventListener<MapZoomChangedEvent> listener) Adds map zoom changed listener.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener
-
addMoveEndListener
public com.vaadin.flow.shared.Registration addMoveEndListener(com.vaadin.flow.component.ComponentEventListener<MapMoveEndEvent> listener) Adds map move end listener.- Parameters:
listener
- the listener to be added- Returns:
- a registration object for removing an event listener
-
getAdditionalPropertiesToUpdate
- Overrides:
getAdditionalPropertiesToUpdate
in classJmixMap
-
createSerializer
- Overrides:
createSerializer
in classJmixMap
-
createMapOptions
- Overrides:
createMapOptions
in classJmixMap
-
fireFeatureClickEvent
protected void fireFeatureClickEvent(EventBus eventBus, AbstractFeatureClickDomEvent event, Feature feature) - Overrides:
fireFeatureClickEvent
in classJmixMap
-
fireSourceFeatureClickEvent
protected void fireSourceFeatureClickEvent(EventBus eventBus, AbstractFeatureClickDomEvent event, Feature feature, AbstractFeatureSource source) - Overrides:
fireSourceFeatureClickEvent
in classJmixMap
-
onMapClickDomEvent
- Overrides:
onMapClickDomEvent
in classJmixMap
-
fireMapClickEvent
-
onMapSingleClickDomEvent
- Overrides:
onMapSingleClickDomEvent
in classJmixMap
-
fireMapSingleClickDomEvent
-
onMapDoubleClickDomEvent
- Overrides:
onMapDoubleClickDomEvent
in classJmixMap
-
fireMapDoubleClickDomEvent
-
onMapMoveEndEvent
- Overrides:
onMapMoveEndEvent
in classJmixMap
-
fireMapMoveEndEvent
-
onMapZoomChangedEvent
- Overrides:
onMapZoomChangedEvent
in classJmixMap
-
fireMapZoomChangeEvent
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetach
in classcom.vaadin.flow.component.Component
-