Interface GeoMap

All Superinterfaces:
Component, Component.BelongToFrame, Component.HasCaption, Component.HasDescription, Component.HasIcon, HasSubParts
All Known Implementing Classes:
GeoMapImpl

@StudioComponent(caption="GeoMap", xmlElement="geoMap", xmlns="http://jmix.io/schema/maps/ui", xmlnsAlias="maps", category="Maps", icon="io/jmix/mapsui/icon/geoMap.svg", canvasIcon="io/jmix/mapsui/icon/geoMap_canvas.svg", canvasIconSize=LARGE, documentationURL="https://docs.jmix.io/jmix/%VERSION%/maps/maps-ui.html") public interface GeoMap extends Component, Component.BelongToFrame, Component.HasIcon, Component.HasCaption, HasSubParts
UI component that displays a geographical data provided by Layers.

The map is built by superposing layers. Initially, GeoMap has the only one layer - CanvasLayer, which is always placed above the other layers. Canvas can be obtained by calling getCanvas() method.

Selected layer of the map is a layer which the map is focused on. Selected layer fires events, reacts on user clicks and can be modified by UI interaction (if the layer is editable). Initially, selected layer is not specified.

Attempting to pass a null value in all places where layer is expected cause NullPointerException to be thrown (except the cases when argument annotated as Nullable).

  • Field Details

  • Method Details

    • addLayer

      @StudioElementsGroup(caption="Layers", xmlElement="layers", icon="io/jmix/mapsui/icon/layers.svg", documentationURL="https://docs.jmix.io/jmix/%VERSION%/maps/layers.html") void addLayer(Layer layer)
      Adds the given layer to the map.

      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.

      Parameters:
      layer - to be added on the map
      Throws:
      IllegalStateException - when attempting to add a tile layer above a vector layer
      IllegalArgumentException - when a layer with the same ID is already on the map
    • removeLayer

      void removeLayer(Layer layer)
      Removes the given layer from the map.
      Parameters:
      layer - to be removed from the map
      Throws:
      IllegalArgumentException - when map does not contain the specified layer
    • getLayer

      @Nonnull <T extends Layer> T getLayer(String layerId)
      Returns a layer by its ID.
      Parameters:
      layerId - ID of a layer
      Returns:
      layer
      Throws:
      IllegalArgumentException - when map does not contain a layer with the specified id
    • getLayerOrNull

      @Nullable <T extends Layer> T getLayerOrNull(String layerId)
      Returns a layer by its ID, or null if the map does not contain a layer with the given ID.
      Parameters:
      layerId - ID of a layer
      Returns:
      layer
    • getLayers

      List<Layer> getLayers()
      Returns the list of layers currently added to the map. The resulting list preserves the order of layers (from the first added layer to the last). The Canvas layer is not included in this list.
    • setCenter

      void setCenter(double x, double y)
      Sets the initial geographic center of the map.
      Parameters:
      x - longitude
      y - latitude
    • getCenter

      org.locationtech.jts.geom.Point getCenter()
      Returns current geographic center of the map.
    • setZoomLevel

      @StudioProperty(name="zoom") void setZoomLevel(double zoomLevel)
      Sets map zoom level.
      The default value is 15.
      Parameters:
      zoomLevel - of the map
    • getZoomLevel

      double getZoomLevel()
      Returns current map zoom level.
    • setMaxZoom

      void setMaxZoom(int maxZoom)
      Sets maximum map zoom level.

      If not specified and at least one tile layer is on the map, the highest of their maxZoom will be used.

      Parameters:
      maxZoom - maximum map zoom level
    • setMinZoom

      void setMinZoom(int minZoom)
      Sets minimum map zoom level.

      If not specified and at least one tile layer is on the map, the lowest of their minZoom will be used.

      Parameters:
      minZoom - minimum map zoom level
    • setReadOnly

      void setReadOnly(boolean readOnly)
      Switches map to a read-only mode. Virtually, it means an impossibility of changing zoom, position, etc., via mouse.
      Parameters:
      readOnly - true/false
    • getCanvas

      CanvasLayer getCanvas()
      Returns the canvas layer of the map.
      Returns:
      Canvas layer
    • selectLayer

      void selectLayer(@Nullable Layer layer)
      Sets the selected (i.e. the active) layer of the map.

      A null parameter deselects currently selected layer.

      Parameters:
      layer - selected layer
      Throws:
      IllegalArgumentException - when map does not contain the specified layer
    • selectLayerById

      default void selectLayerById(String layerId)
      Sets the selected (i.e. the active) layer of the map by the given layer's ID.
      Parameters:
      layerId - ID of the layer
      Throws:
      IllegalArgumentException - when map does not contain the specified layer
    • getSelectedLayer

      @Nullable Layer getSelectedLayer()
      Returns the selected layer of the map.
      Returns:
      the selected layer or null when none of the layers is selected
    • getBounds

      GeoMap.Bounds getBounds()
      Returns the bounds of the map which define the viewport of the map.
    • zoomToBounds

      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.
      Parameters:
      topLeft - NorthWest point
      bottomRight - SouthEast point
    • zoomToGeometry

      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.

      Note: if the given geometry is point, map will be centered to this point with the current zoom level.

    • openPopup

      void openPopup(PopupWindow popupWindow)
      Opens the given popup window.
    • addClickListener

      Subscription addClickListener(Consumer<GeoMap.ClickEvent> listener)
      Registers a new click listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addRightClickListener

      Subscription addRightClickListener(Consumer<GeoMap.RightClickEvent> listener)
      Registers a new right click listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addMoveEndListener

      Subscription addMoveEndListener(Consumer<GeoMap.MoveEndEvent> listener)
      Registers a new move end listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addZoomEndListener

      Subscription addZoomEndListener(Consumer<GeoMap.ZoomEndEvent> listener)
      Registers a new zoom end listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addDragEndListener

      Subscription addDragEndListener(Consumer<GeoMap.DragEndEvent> listener)
      Registers a new drag end listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addLayerAddedListener

      Subscription addLayerAddedListener(Consumer<GeoMap.LayerAddedEvent> listener)
      Registers a new layer added listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addLayerRemovedListener

      Subscription addLayerRemovedListener(Consumer<GeoMap.LayerRemovedEvent> listener)
      Registers a new layer removed listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addSelectedLayerChangedListener

      Subscription addSelectedLayerChangedListener(Consumer<GeoMap.SelectedLayerChangedEvent> listener)
      Registers a new selected layer changed listener.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source