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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBaseLayer(LeafletLayer baseLayer, String name)
    Add a base layer with given name.
    com.vaadin.shared.Registration
     
    com.vaadin.shared.Registration
     
    void
    addComponent(com.vaadin.ui.Component c)
     
    com.vaadin.shared.Registration
     
    void
     
    com.vaadin.shared.Registration
     
    void
     
    com.vaadin.shared.Registration
     
    com.vaadin.shared.Registration
     
    void
    addOverlay(LeafletLayer overlay, String name)
     
    com.vaadin.shared.Registration
     
    com.vaadin.shared.Registration
     
    com.vaadin.shared.Registration
     
    void
    beforeClientResponse(boolean initial)
     
    void
     
    void
    flyTo(Point center, Double zoom)
     
     
    Gets the bounds of the maps "viewport".
     
    int
     
    org.locationtech.jts.geom.Geometry
     
     
     
    protected LeafletMapState
     
    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>
     
    void
    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
     
    void
     
    void
    replaceComponent(com.vaadin.ui.Component oldComponent, com.vaadin.ui.Component newComponent)
     
    void
     
    void
    setBoxZoomEnabled(boolean boxZoom)
     
    void
    setCenter(double lat, double lon)
     
    void
    setCenter(Bounds bounds)
     
    void
    setCenter(Point center)
     
    void
    setCenter(Point center, Double zoom)
     
    void
    setCenter(org.locationtech.jts.geom.Point jtsPoint)
     
    void
    Deprecated.
    use addControl() instead
    void
    setCrs(Crs lc)
    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
    Updates given layers directly on the client side when position is located.
    void
    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
     
    void
    setMinZoom(int minZoom)
     
    void
    setReadOnly(boolean readOnly)
     
    void
    setScrollWheelZoomEnabled(boolean scrollWheelZoom)
     
    void
    setTouchZoomEnabled(boolean touchZoom)
     
    void
    setView(Double lat, Double lon, Double zoom)
     
    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
     
    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 interface com.vaadin.server.ClientConnector
      Overrides:
      beforeClientResponse in class com.vaadin.ui.AbstractComponent
    • detach

      public void detach()
      Specified by:
      detach in interface com.vaadin.server.ClientConnector
      Overrides:
      detach in class com.vaadin.ui.AbstractComponent
    • getState

      protected LeafletMapState getState(boolean markAsDirty)
      Overrides:
      getState in class com.vaadin.ui.AbstractComponentContainer
    • getState

      protected LeafletMapState getState()
      Overrides:
      getState in class com.vaadin.ui.AbstractComponentContainer
    • replaceComponent

      public void replaceComponent(com.vaadin.ui.Component oldComponent, com.vaadin.ui.Component newComponent)
    • addBaseLayer

      public void addBaseLayer(LeafletLayer baseLayer, String name)
      Add a base layer with given name.
      Parameters:
      baseLayer - the layer to be added
      name - to be used in LayerControl, null if layer should not be displayed in the layer control
    • getZoomControl

      public LZoom getZoomControl()
    • getLayersControl

      public LLayers getLayersControl()
    • addControl

      public void addControl(AbstractControl control)
    • removeControl

      public void removeControl(AbstractControl control)
    • addOverlay

      public void addOverlay(LeafletLayer overlay, String name)
    • addLayer

      public void addLayer(LeafletLayer layer)
    • removeLayer

      public void removeLayer(LeafletLayer layer)
    • addComponent

      public void addComponent(com.vaadin.ui.Component c)
      Specified by:
      addComponent in interface com.vaadin.ui.ComponentContainer
      Overrides:
      addComponent in class com.vaadin.ui.AbstractComponentContainer
    • removeComponent

      public void removeComponent(com.vaadin.ui.Component c)
      Specified by:
      removeComponent in interface com.vaadin.ui.ComponentContainer
      Overrides:
      removeComponent in class com.vaadin.ui.AbstractComponentContainer
    • getComponentCount

      public int getComponentCount()
    • hasControl

      public boolean hasControl(Class<? extends AbstractControl> leafletControl)
    • hasComponent

      public boolean hasComponent(com.vaadin.ui.Component component)
    • iterator

      public Iterator<com.vaadin.ui.Component> iterator()
    • setView

      public void setView(Double lat, Double lon, Double zoom)
    • setCenter

      public void setCenter(double lat, double lon)
    • setCenter

      public void setCenter(Point center, Double zoom)
    • flyTo

      public void flyTo(Point center, Double zoom)
    • setCenter

      public void setCenter(Point center)
    • setCenter

      public void setCenter(org.locationtech.jts.geom.Point jtsPoint)
    • setZoomLevel

      public void setZoomLevel(double zoomLevel)
    • addLocateListener

      public com.vaadin.shared.Registration addLocateListener(LeafletLocateListener listener)
    • addClickListener

      public com.vaadin.shared.Registration addClickListener(LeafletClickListener listener)
    • addMoveEndListener

      public com.vaadin.shared.Registration addMoveEndListener(LeafletMoveEndListener moveEndListener)
    • addZoomEndListener

      public com.vaadin.shared.Registration addZoomEndListener(LeafletZoomEndListener zoomEndListener)
    • addDragEndListener

      public com.vaadin.shared.Registration addDragEndListener(LeafletDragEndListener dragEndListener)
    • addContextMenuListener

      public com.vaadin.shared.Registration addContextMenuListener(LeafletContextMenuListener listener)
    • addBaseLayerChangeListener

      public com.vaadin.shared.Registration addBaseLayerChangeListener(LeafletBaseLayerChangeListener listener)
    • addOverlayAddListener

      public com.vaadin.shared.Registration addOverlayAddListener(LeafletOverlayAddListener listener)
    • addOverlayRemoveListener

      public com.vaadin.shared.Registration addOverlayRemoveListener(LeafletOverlayRemoveListener listener)
    • setCenter

      public void setCenter(Bounds bounds)
    • getZoomLevel

      public Double getZoomLevel()
    • zoomToExtent

      public void zoomToExtent(Bounds bounds)
    • zoomToExtent

      public void zoomToExtent(org.locationtech.jts.geom.Geometry geometry)
    • getBounds

      public Bounds 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 public void setControls(List<Control> controls)
      Deprecated.
      use addControl() instead
      Parameters:
      controls - the list of controls to be shown
    • getCenter

      public Point getCenter()
    • setAttributionPrefix

      public void setAttributionPrefix(String prefix)
    • getAttributionPrefix

      public String getAttributionPrefix()
    • zoomToContent

      public void zoomToContent(LeafletLayer l)
    • setMaxBounds

      public void setMaxBounds(Bounds 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
    • 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

      public Crs getCrs()
    • setCrs

      public void setCrs(Crs lc)
      Specify the CRS to use for the whole Map.
      Parameters:
      lc - The CRS to use (one from a limited range)
    • setCustomCrs

      public 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. 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 a
      b - transformation parameter b
      c - transformation parameter c
      d - 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 value
      min_y - the minimum y value
      max_x - the maximum x value
      max_y - the maximum y value
      a - transformation parameter a
      b - transformation parameter b
      c - transformation parameter c
      d - transformation parameter d
    • setCustomInitOption

      public void setCustomInitOption(String key, boolean b)
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Overrides:
      setReadOnly in class com.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

      public void setZoomSnap(Double zoomSnap)
      Parameters:
      zoomSnap -
      See Also:
    • setZoomDelta

      public void setZoomDelta(Double zoomDelta)
      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 continuously
      highAccuracy - true if high accuracy should be requested
      updateView - 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

      public void setLayersToUpdateOnLocate(AbstractLeafletLayer... layers)
      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 class com.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 coordinate
      y - the y pixel coordinate
      callback - the callback to notify when translation is done