Class GeoMapImpl

All Implemented Interfaces:
GeoMap, AttachNotifier, Component, Component.BelongToFrame, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper, HasContextHelp, HasDebugId, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasSubParts

public class GeoMapImpl extends AbstractComponent<LMap> implements GeoMap
UI component that displays a geographical data provided by layers. Based on Leaflet JS.
  • Constructor Details

    • GeoMapImpl

      public GeoMapImpl()
  • Method Details

    • setApplicationContext

      @Autowired public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Overrides:
      setApplicationContext in class AbstractComponent<LMap>
    • addLayer

      public void addLayer(Layer layer)
      Description copied from interface: GeoMap
      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.

      Specified by:
      addLayer in interface GeoMap
      Parameters:
      layer - to be added on the map
    • removeLayer

      public void removeLayer(Layer layer)
      Description copied from interface: GeoMap
      Removes the given layer from the map.
      Specified by:
      removeLayer in interface GeoMap
      Parameters:
      layer - to be removed from the map
    • getLayer

      @Nonnull public <T extends Layer> T getLayer(String layerId)
      Description copied from interface: GeoMap
      Returns a layer by its ID.
      Specified by:
      getLayer in interface GeoMap
      Parameters:
      layerId - ID of a layer
      Returns:
      layer
    • getLayerOrNull

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

      public List<Layer> getLayers()
      Description copied from interface: GeoMap
      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.
      Specified by:
      getLayers in interface GeoMap
    • setCenter

      public void setCenter(double x, double y)
      Description copied from interface: GeoMap
      Sets the initial geographic center of the map.
      Specified by:
      setCenter in interface GeoMap
      Parameters:
      x - longitude
      y - latitude
    • getCenter

      public org.locationtech.jts.geom.Point getCenter()
      Description copied from interface: GeoMap
      Returns current geographic center of the map.
      Specified by:
      getCenter in interface GeoMap
    • setZoomLevel

      public void setZoomLevel(double zoomLevel)
      Set map zoom level.
      Specified by:
      setZoomLevel in interface GeoMap
      Parameters:
      zoomLevel - of the map
    • getZoomLevel

      public double getZoomLevel()
      Description copied from interface: GeoMap
      Returns current map zoom level.
      Specified by:
      getZoomLevel in interface GeoMap
    • setMaxZoom

      public void setMaxZoom(int maxZoom)
      Set maximum map zoom level.
      Specified by:
      setMaxZoom in interface GeoMap
      Parameters:
      maxZoom - maximum map zoom level
    • setMinZoom

      public void setMinZoom(int minZoom)
      Set minimum map zoom level.
      Specified by:
      setMinZoom in interface GeoMap
      Parameters:
      minZoom - minimum map zoom level
    • setReadOnly

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

      public CanvasLayer getCanvas()
      Description copied from interface: GeoMap
      Returns the canvas layer of the map.
      Specified by:
      getCanvas in interface GeoMap
      Returns:
      Canvas layer
    • selectLayer

      public void selectLayer(Layer layer)
      Description copied from interface: GeoMap
      Sets the selected (i.e. the active) layer of the map.

      A null parameter deselects currently selected layer.

      Specified by:
      selectLayer in interface GeoMap
      Parameters:
      layer - selected layer
    • getSelectedLayer

      public Layer getSelectedLayer()
      Description copied from interface: GeoMap
      Returns the selected layer of the map.
      Specified by:
      getSelectedLayer in interface GeoMap
      Returns:
      the selected layer or null when none of the layers is selected
    • getBounds

      public GeoMap.Bounds getBounds()
      Description copied from interface: GeoMap
      Returns the bounds of the map which define the viewport of the map.
      Specified by:
      getBounds in interface GeoMap
    • zoomToBounds

      public void zoomToBounds(org.locationtech.jts.geom.Point topLeft, org.locationtech.jts.geom.Point bottomRight)
      Description copied from interface: GeoMap
      Sets a map view that contains the given geographical bounds with the maximum zoom level possible.
      Specified by:
      zoomToBounds in interface GeoMap
      Parameters:
      topLeft - NorthWest point
      bottomRight - SouthEast point
    • zoomToGeometry

      public void zoomToGeometry(org.locationtech.jts.geom.Geometry geometry)
      Description copied from interface: GeoMap
      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.

      Specified by:
      zoomToGeometry in interface GeoMap
    • openPopup

      public void openPopup(PopupWindow popupWindow)
      Description copied from interface: GeoMap
      Opens the given popup window.
      Specified by:
      openPopup in interface GeoMap
    • addClickListener

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

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

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

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

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

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

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

      public Subscription addSelectedLayerChangedListener(Consumer<GeoMap.SelectedLayerChangedEvent> listener)
      Description copied from interface: GeoMap
      Registers a new selected layer changed listener.
      Specified by:
      addSelectedLayerChangedListener in interface GeoMap
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • getEventHub

      protected EventHub getEventHub()
      Overrides:
      getEventHub in class AbstractComponent<LMap>
    • getGeoObjectWrappersMap

      public <T> Map<?,GeoObjectWrapper<T>> getGeoObjectWrappersMap(VectorLayer<T> layer)
      Returns a map of pairs [geo-object ID: geoObjectWrapper] for geo-objects of the given vector layer.

      In case when geo-object's geometry is null, then wrapper is also null. So perform null check before operating with a wrapper. Geo-object wrappers can be replaced with another instance after layer refresh or geometry update, so always use this map to get the relevant wrapper instance.

      Throws:
      IllegalArgumentException - when map does not contain the specified layer
    • getSubPart

      @Nullable public Object getSubPart(String name)
      Specified by:
      getSubPart in interface HasSubParts