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.IncorrectConcurrentAccessHandlerNested 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.DetachListenerNested 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.ListenerNested classes/interfaces inherited from interface com.vaadin.ui.Component.HasContextHelp
com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent, com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickListenerNested 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.ComponentDetachListenerNested 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, requiredErrorFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBaseLayer(LeafletLayer baseLayer, String name) Add a base layer with given name.com.vaadin.shared.Registrationcom.vaadin.shared.RegistrationaddClickListener(LeafletClickListener listener) voidaddComponent(com.vaadin.ui.Component c) com.vaadin.shared.RegistrationvoidaddControl(AbstractControl control) com.vaadin.shared.RegistrationaddDragEndListener(LeafletDragEndListener dragEndListener) voidaddLayer(LeafletLayer layer) com.vaadin.shared.RegistrationaddLocateListener(LeafletLocateListener listener) com.vaadin.shared.RegistrationaddMoveEndListener(LeafletMoveEndListener moveEndListener) voidaddOverlay(LeafletLayer overlay, String name) com.vaadin.shared.Registrationcom.vaadin.shared.Registrationcom.vaadin.shared.RegistrationaddZoomEndListener(LeafletZoomEndListener zoomEndListener) voidbeforeClientResponse(boolean initial) voiddetach()voidGets the bounds of the maps "viewport".intorg.locationtech.jts.geom.GeometrygetCrs()protected LeafletMapStategetState()protected LeafletMapStategetState(boolean markAsDirty) booleanhasComponent(com.vaadin.ui.Component component) booleanhasControl(Class<? extends AbstractControl> leafletControl) booleanbooleanbooleanbooleanbooleanbooleanbooleanIterator<com.vaadin.ui.Component>iterator()voidlocate()Tries to detect the users geolocation.voidlocate(boolean watch, boolean highAccuracy, boolean updateView) Tries to detect the users geolocation.voidremoveComponent(com.vaadin.ui.Component c) voidremoveControl(AbstractControl control) voidremoveLayer(LeafletLayer layer) voidreplaceComponent(com.vaadin.ui.Component oldComponent, com.vaadin.ui.Component newComponent) voidsetAttributionPrefix(String prefix) voidsetBoxZoomEnabled(boolean boxZoom) voidsetCenter(double lat, double lon) voidvoidvoidvoidsetCenter(org.locationtech.jts.geom.Point jtsPoint) voidsetControls(List<Control> controls) Deprecated.use addControl() insteadvoidSpecify the CRS to use for the whole Map.voidsetCustomCrs(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.voidsetCustomCrs(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.voidsetCustomInitOption(String key, boolean b) voidsetDoubleClickZoomEnabled(boolean doubleClickZoom) voidsetDraggingEnabled(boolean dragging) voidsetKeyboardEnabled(boolean keyboard) voidsetLayersToUpdateOnLocate(AbstractLeafletLayer... layers) Updates given layers directly on the client side when position is located.voidsetMaxBounds(Bounds bounds) Sets the area into where the viewport is restricted.voidsetMaxBounds(org.locationtech.jts.geom.Geometry bounds) Sets the area into where the viewport is restricted.voidsetMaxZoom(int maxZoom) voidsetMinLocatationUpdateInterval(int millis) voidsetMinZoom(int minZoom) voidsetReadOnly(boolean readOnly) voidsetScrollWheelZoomEnabled(boolean scrollWheelZoom) voidsetTouchZoomEnabled(boolean touchZoom) voidvoidsetZoomDelta(Double zoomDelta) voidsetZoomLevel(double zoomLevel) voidsetZoomSnap(Double zoomSnap) voidStops detecting users geolocation.voidtranslatePixelCoordinates(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.voidCalculates extent of all contained components that are not "baselayers".voidvoidzoomToExtent(Bounds bounds) voidzoomToExtent(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, setWidthMethods 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, writeDesignMethods 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, updateDiffstateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods 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, setErrorHandlerMethods 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, writeDesignMethods inherited from interface com.vaadin.shared.Connector
getConnectorIdMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods 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:
beforeClientResponsein interfacecom.vaadin.server.ClientConnector- Overrides:
beforeClientResponsein classcom.vaadin.ui.AbstractComponent
-
detach
public void detach()- Specified by:
detachin interfacecom.vaadin.server.ClientConnector- Overrides:
detachin classcom.vaadin.ui.AbstractComponent
-
getState
- Overrides:
getStatein classcom.vaadin.ui.AbstractComponentContainer
-
getState
- Overrides:
getStatein 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:
addComponentin interfacecom.vaadin.ui.ComponentContainer- Overrides:
addComponentin classcom.vaadin.ui.AbstractComponentContainer
-
removeComponent
public void removeComponent(com.vaadin.ui.Component c) - Specified by:
removeComponentin interfacecom.vaadin.ui.ComponentContainer- Overrides:
removeComponentin 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:
setReadOnlyin 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:
isReadOnlyin 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
-