Package io.jmix.mapsui.widget.leaflet
Class LMap
java.lang.Object
com.vaadin.server.AbstractClientConnector
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractComponentContainer
io.jmix.mapsui.widget.leaflet.LMap
- All Implemented Interfaces:
com.vaadin.event.ContextClickEvent.ContextClickNotifier
,com.vaadin.event.MethodEventSource
,com.vaadin.server.ClientConnector
,com.vaadin.server.Sizeable
,com.vaadin.shared.Connector
,com.vaadin.ui.Component
,com.vaadin.ui.Component.HasContextHelp
,com.vaadin.ui.ComponentContainer
,com.vaadin.ui.HasComponents
,com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier
,Serializable
,Iterable<com.vaadin.ui.Component>
public class LMap
extends com.vaadin.ui.AbstractComponentContainer
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.server.AbstractClientConnector
com.vaadin.server.AbstractClientConnector.IncorrectConcurrentAccessHandler
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.HasContextHelp, com.vaadin.ui.Component.Listener
Nested classes/interfaces inherited from interface com.vaadin.ui.Component.HasContextHelp
com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent, com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickListener
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit
-
Field Summary
Fields inherited from class com.vaadin.ui.AbstractComponent
componentErrorProvider, DESIGN_ATTR_PLAIN_TEXT, requiredError
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBaseLayer
(LeafletLayer baseLayer, String name) Add a base layer with given name.com.vaadin.shared.Registration
com.vaadin.shared.Registration
addClickListener
(LeafletClickListener listener) void
addComponent
(com.vaadin.ui.Component c) com.vaadin.shared.Registration
void
addControl
(AbstractControl control) com.vaadin.shared.Registration
addDragEndListener
(LeafletDragEndListener dragEndListener) void
addLayer
(LeafletLayer layer) com.vaadin.shared.Registration
addLocateListener
(LeafletLocateListener listener) com.vaadin.shared.Registration
addMoveEndListener
(LeafletMoveEndListener moveEndListener) void
addOverlay
(LeafletLayer overlay, String name) com.vaadin.shared.Registration
com.vaadin.shared.Registration
com.vaadin.shared.Registration
addZoomEndListener
(LeafletZoomEndListener zoomEndListener) void
beforeClientResponse
(boolean initial) void
detach()
void
Gets the bounds of the maps "viewport".int
org.locationtech.jts.geom.Geometry
getCrs()
protected LeafletMapState
getState()
protected LeafletMapState
getState
(boolean markAsDirty) boolean
hasComponent
(com.vaadin.ui.Component component) boolean
hasControl
(Class<? extends AbstractControl> leafletControl) boolean
boolean
boolean
boolean
boolean
boolean
boolean
Iterator<com.vaadin.ui.Component>
iterator()
void
locate()
Tries to detect the users geolocation.void
locate
(boolean watch, boolean highAccuracy, boolean updateView) Tries to detect the users geolocation.void
removeComponent
(com.vaadin.ui.Component c) void
removeControl
(AbstractControl control) void
removeLayer
(LeafletLayer layer) void
replaceComponent
(com.vaadin.ui.Component oldComponent, com.vaadin.ui.Component newComponent) void
setAttributionPrefix
(String prefix) void
setBoxZoomEnabled
(boolean boxZoom) void
setCenter
(double lat, double lon) void
void
void
void
setCenter
(org.locationtech.jts.geom.Point jtsPoint) void
setControls
(List<Control> controls) Deprecated.use addControl() insteadvoid
Specify the CRS to use for the whole Map.void
setCustomCrs
(String name, double min_x, double min_y, double max_x, double max_y, double a, double b, double c, double d) Adds and uses a new Crs definition and makes it immediately available for use inside a Map.void
setCustomCrs
(String name, String projection, double a, double b, double c, double d) Adds and uses a new Crs definition and makes it immediately available for use inside a Map.void
setCustomInitOption
(String key, boolean b) void
setDoubleClickZoomEnabled
(boolean doubleClickZoom) void
setDraggingEnabled
(boolean dragging) void
setKeyboardEnabled
(boolean keyboard) void
setLayersToUpdateOnLocate
(AbstractLeafletLayer... layers) Updates given layers directly on the client side when position is located.void
setMaxBounds
(Bounds bounds) Sets the area into where the viewport is restricted.void
setMaxBounds
(org.locationtech.jts.geom.Geometry bounds) Sets the area into where the viewport is restricted.void
setMaxZoom
(int maxZoom) void
setMinLocatationUpdateInterval
(int millis) void
setMinZoom
(int minZoom) void
setReadOnly
(boolean readOnly) void
setScrollWheelZoomEnabled
(boolean scrollWheelZoom) void
setTouchZoomEnabled
(boolean touchZoom) void
void
setZoomDelta
(Double zoomDelta) void
setZoomLevel
(double zoomLevel) void
setZoomSnap
(Double zoomSnap) void
Stops detecting users geolocation.void
translatePixelCoordinates
(int x, int y, com.vaadin.server.SerializableConsumer<Point> callback) Translates given parameters (x/y pixel coordinates relative to the map) to actual coordinates on the client side and passes the values to the callback.void
Calculates extent of all contained components that are not "baselayers".void
void
zoomToExtent
(Bounds bounds) void
zoomToExtent
(org.locationtech.jts.geom.Geometry geometry) Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addComponentAttachListener, addComponentDetachListener, addComponents, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, setHeight, setWidth
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addContextHelpIconClickListener, addListener, addShortcutListener, addStyleName, attach, ensureContextHelpInitialized, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireContextHelpClick, focus, getActionManager, getCaption, getComponentError, getComponentErrorProvider, getContextHelpText, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getJTestId, getLocale, getParent, getPrimaryStyleName, getRequiredError, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isContextHelpTextHtmlEnabled, isEnabled, isOrHasAncestor, isRequiredIndicatorVisible, isResponsive, isVisible, readDesign, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setComponentErrorProvider, setContextHelpText, setContextHelpTextHtmlEnabled, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setJTestId, setLocale, setParent, setPrimaryStyleName, setRequiredError, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined, writeDesign
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getIncorrectConcurrentAccessHandler, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setConnectorResource, setErrorHandler, setIncorrectConcurrentAccessHandler, setResource, updateDiffstate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getJTestId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setJTestId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidthFull, setWidthUndefined
-
Constructor Details
-
LMap
public LMap()
-
-
Method Details
-
beforeClientResponse
public void beforeClientResponse(boolean initial) - Specified by:
beforeClientResponse
in interfacecom.vaadin.server.ClientConnector
- Overrides:
beforeClientResponse
in classcom.vaadin.ui.AbstractComponent
-
detach
public void detach()- Specified by:
detach
in interfacecom.vaadin.server.ClientConnector
- Overrides:
detach
in classcom.vaadin.ui.AbstractComponent
-
getState
- Overrides:
getState
in classcom.vaadin.ui.AbstractComponentContainer
-
getState
- Overrides:
getState
in classcom.vaadin.ui.AbstractComponentContainer
-
replaceComponent
public void replaceComponent(com.vaadin.ui.Component oldComponent, com.vaadin.ui.Component newComponent) -
addBaseLayer
Add a base layer with given name.- Parameters:
baseLayer
- the layer to be addedname
- to be used in LayerControl, null if layer should not be displayed in the layer control
-
getZoomControl
-
getLayersControl
-
addControl
-
removeControl
-
addOverlay
-
addLayer
-
removeLayer
-
addComponent
public void addComponent(com.vaadin.ui.Component c) - Specified by:
addComponent
in interfacecom.vaadin.ui.ComponentContainer
- Overrides:
addComponent
in classcom.vaadin.ui.AbstractComponentContainer
-
removeComponent
public void removeComponent(com.vaadin.ui.Component c) - Specified by:
removeComponent
in interfacecom.vaadin.ui.ComponentContainer
- Overrides:
removeComponent
in classcom.vaadin.ui.AbstractComponentContainer
-
getComponentCount
public int getComponentCount() -
hasControl
-
hasComponent
public boolean hasComponent(com.vaadin.ui.Component component) -
iterator
-
setView
-
setCenter
public void setCenter(double lat, double lon) -
setCenter
public void setCenter(org.locationtech.jts.geom.Point jtsPoint) -
setZoomLevel
public void setZoomLevel(double zoomLevel) -
addLocateListener
-
addClickListener
-
addMoveEndListener
-
addZoomEndListener
-
addDragEndListener
-
addContextMenuListener
-
addBaseLayerChangeListener
public com.vaadin.shared.Registration addBaseLayerChangeListener(LeafletBaseLayerChangeListener listener) -
addOverlayAddListener
-
addOverlayRemoveListener
public com.vaadin.shared.Registration addOverlayRemoveListener(LeafletOverlayRemoveListener listener) -
getZoomLevel
-
zoomToExtent
public void zoomToExtent(org.locationtech.jts.geom.Geometry geometry) -
getBounds
Gets the bounds of the maps "viewport". The bounds are not known during initialization as we cannot be sure about the size of the map. Thus, if you for example want to initialize the map content based on the currently visible viewport, add a MoveEndListener to your map, which is notified after the initial render and each time the user moves or zooms the viewport.- Returns:
- the last know bounds (reported by client or set by zoomToExtennt) or null if not known.
-
zoomToContent
public void zoomToContent()Calculates extent of all contained components that are not "baselayers". -
getContentBounds
public org.locationtech.jts.geom.Geometry getContentBounds() -
setControls
Deprecated.use addControl() instead- Parameters:
controls
- the list of controls to be shown
-
getCenter
-
setAttributionPrefix
-
getAttributionPrefix
-
zoomToContent
-
setMaxBounds
public void setMaxBounds(org.locationtech.jts.geom.Geometry bounds) Sets the area into where the viewport is restricted.- Parameters:
bounds
- the bounds of where the viewport of the map should be limited to
-
setMinZoom
public void setMinZoom(int minZoom) -
setMaxZoom
public void setMaxZoom(int maxZoom) -
getCrs
-
setCustomCrs
Adds and uses a new Crs definition and makes it immediately available for use inside a Map. The new Crs extends Crs.Simple, uses the Projection as specified in the parameters and an affine transform as specified by the a, b, c, d parameters). For the meaning of the affine transform parameters, see: http://leafletjs.com/reference.html#transformation.- Parameters:
name
- Name for the new Crs.projection
- Name of the projection for this new Crs. It needs to be the name of a valid projection defined in L.Projection (LonLat, SphericalMercator, Mercator).a
- transformation parameter ab
- transformation parameter bc
- transformation parameter cd
- transformation parameter d
-
setCustomCrs
public void setCustomCrs(String name, double min_x, double min_y, double max_x, double max_y, double a, double b, double c, double d) Adds and uses a new Crs definition and makes it immediately available for use inside a Map. The new Crs extends Crs.Simple, uses a plat-carré projection with the extents given by the min_* and max_* parameters. For the meaning of the affine transform parameters, see: http://leafletjs.com/reference.html#transformation.- Parameters:
name
- Name for the new Crs.min_x
- the minimum x valuemin_y
- the minimum y valuemax_x
- the maximum x valuemax_y
- the maximum y valuea
- transformation parameter ab
- transformation parameter bc
- transformation parameter cd
- transformation parameter d
-
setCustomInitOption
-
setReadOnly
public void setReadOnly(boolean readOnly) - Overrides:
setReadOnly
in classcom.vaadin.ui.AbstractComponent
-
setDraggingEnabled
public void setDraggingEnabled(boolean dragging) - Parameters:
dragging
- true if dragging map should be possible- See Also:
-
isDraggingEnabled
public boolean isDraggingEnabled()- Returns:
- true if dragging is enabled
- See Also:
-
setTouchZoomEnabled
public void setTouchZoomEnabled(boolean touchZoom) - Parameters:
touchZoom
- true if touch zoom should be enabled- See Also:
-
isTouchZoomEnabled
public boolean isTouchZoomEnabled()- Returns:
- true if touch zoom should be enabled
- See Also:
-
setDoubleClickZoomEnabled
public void setDoubleClickZoomEnabled(boolean doubleClickZoom) - Parameters:
doubleClickZoom
- true if double click zooming should be enabled- See Also:
-
isDoubleZoomEnabled
public boolean isDoubleZoomEnabled()- Returns:
- true if double click zooming is enabled
- See Also:
-
setBoxZoomEnabled
public void setBoxZoomEnabled(boolean boxZoom) - Parameters:
boxZoom
- true if box zoom mode should be enabled- See Also:
-
isBoxZoomEnabled
public boolean isBoxZoomEnabled()- Returns:
- true if box zoom mode is enabled
- See Also:
-
setScrollWheelZoomEnabled
public void setScrollWheelZoomEnabled(boolean scrollWheelZoom) - Parameters:
scrollWheelZoom
- true if zooming with scroll wheel should be enabled- See Also:
-
setZoomSnap
- Parameters:
zoomSnap
-- See Also:
-
setZoomDelta
- Parameters:
zoomDelta
-- See Also:
-
isScrollWheelZoomEnabled
public boolean isScrollWheelZoomEnabled()- Returns:
- true if scroll wheel zoom is enabled
- See Also:
-
setKeyboardEnabled
public void setKeyboardEnabled(boolean keyboard) - Parameters:
keyboard
- true if keyboard usage should be enabled- See Also:
-
isKeyboardZoomEnabled
public boolean isKeyboardZoomEnabled()- Returns:
- true if keyboard zoom is enabled
- See Also:
-
locate
public void locate()Tries to detect the users geolocation. -
locate
public void locate(boolean watch, boolean highAccuracy, boolean updateView) Tries to detect the users geolocation.- Parameters:
watch
- true if location should be updated continuouslyhighAccuracy
- true if high accuracy should be requestedupdateView
- true if the viewport should be centered to the latest position, with appropriate zoom level
-
stopLocate
public void stopLocate()Stops detecting users geolocation. -
setMinLocatationUpdateInterval
public void setMinLocatationUpdateInterval(int millis) - Parameters:
millis
- the minimum interval in milliseconds that server side gets notified about the new location (via LeafletLocateListener), if watch option is used. Can be handy if you want to limit the amount of client server traffic. The default is 5000ms.
-
setLayersToUpdateOnLocate
Updates given layers directly on the client side when position is located. Typically used to show the location of the user without any latency and extra client-server communication.- Parameters:
layers
- that should be updated, only LMarker, LCircle and LCircleMarker are currently supported. If the layer is of type LCircle, the radius is set to accuracy of the location event
-
isReadOnly
public boolean isReadOnly()- Overrides:
isReadOnly
in classcom.vaadin.ui.AbstractComponent
-
translatePixelCoordinates
public void translatePixelCoordinates(int x, int y, com.vaadin.server.SerializableConsumer<Point> callback) Translates given parameters (x/y pixel coordinates relative to the map) to actual coordinates on the client side and passes the values to the callback.Note, only one callback is allowed at once.
- Parameters:
x
- the x pixel coordinatey
- the y pixel coordinatecallback
- the callback to notify when translation is done
-