Interface CanvasLayer

All Superinterfaces:
Layer

public interface CanvasLayer extends Layer
A utility layer of GeoMap used to display vector geometries and draw geometries via UI.

GeoMap UI component has the canvas initially and it can be obtained by calling GeoMap.getCanvas() method.

Before attempting to draw geometries make sure that the canvas is selected on a map. It can be done by invoking geoMap.selectLayerById("canvas") on GeoMap or specifying the selected layer in the XML-descriptor of the GeoMap.

  • Field Details

  • Method Details

    • addPoint

      CanvasLayer.Point addPoint(org.locationtech.jts.geom.Point point)
      Adds a JTS point to the canvas.

      This method returns an instance of CanvasLayer.Point which controls the added point on the canvas. This object can be used to define point's appearance, subscribe to events. You can also pass this object to removePoint(Point) method to remove the point from the canvas.

      Parameters:
      point - JTS point
      Returns:
      canvas point
    • addPolyline

      CanvasLayer.Polyline addPolyline(org.locationtech.jts.geom.LineString polyline)
      Adds a JTS linestring to the canvas.

      This method returns an instance of CanvasLayer.Polyline which controls the added polyline on the canvas. This object can be used to define polyline's appearance, subscribe to events. You can also pass this object to removePolyline(Polyline) method to remove the polyline from the canvas.

      Parameters:
      polyline - JTS linestring
      Returns:
      canvas polyline
    • addPolygon

      CanvasLayer.Polygon addPolygon(org.locationtech.jts.geom.Polygon polygon)
      Adds a JTS polygon to the canvas.

      This method returns an instance of CanvasLayer.Polygon which controls the added polygon on the canvas. This object can be used to define polygon's appearance, subscribe to events. You can also pass this object to removePolygon(Polygon) method to remove the polygon from the canvas.

      Parameters:
      polygon - JTS polygon
      Returns:
      canvas polygon
    • removePoint

      void removePoint(CanvasLayer.Point point)
      Removes a point from the canvas.
      Parameters:
      point - canvas point
    • removePolyline

      void removePolyline(CanvasLayer.Polyline polyline)
      Removes a polyline from the canvas.
      Parameters:
      polyline - canvas polyline
    • removePolygon

      void removePolygon(CanvasLayer.Polygon polygon)
      Removes a polygon from the canvas.
      Parameters:
      polygon - canvas polygon
    • clear

      void clear()
      Removes all geometries from the canvas.
    • drawPoint

      void drawPoint(Consumer<CanvasLayer.Point> afterPointDrawnAction)
      Activates the point drawing mode.

      After the point is drawn the afterPointDrawnAction is invoked. This action can be used to obtain the geometry value or to apply additional settings for the point.

      Note that drawn point stays on the canvas, but it can be removed in the afterPointDrawnAction.

      Parameters:
      afterPointDrawnAction - consumer that takes drawn CanvasLayer.Point as an argument
    • drawPolyline

      void drawPolyline(Consumer<CanvasLayer.Polyline> afterPolylineDrawnAction)
      Activates the polyline drawing mode.

      After the polyline is drawn the afterPolylineDrawnAction is invoked. This action can be used to obtain the geometry value or to apply additional settings for the polyline.

      Note that drawn polyline stays on the canvas, but it can be removed in the afterPolylineDrawnAction.

      Parameters:
      afterPolylineDrawnAction - consumer that takes drawn CanvasLayer.Polyline as an argument
    • drawPolygon

      void drawPolygon(Consumer<CanvasLayer.Polygon> afterPolygonDrawnAction)
      Activates the polygon drawing mode.

      After the polygon is drawn the afterPolygonDrawnAction is invoked. This action can be used to obtain the geometry value or to apply additional settings for the polygon.

      Note that drawn polygon stays on the canvas, but it can be removed in the afterPolygonDrawnAction.

      Parameters:
      afterPolygonDrawnAction - consumer that takes drawn CanvasLayer.Polygon as an argument
    • cancelDrawing

      void cancelDrawing()
      Cancels the drawing mode.
    • getContextMenuDelegate

      Returns a function which is used to build context menu for geometries.
    • setContextMenuDelegate

      void setContextMenuDelegate(Function<ContextMenuInvocationContext,ContextMenu> contextMenuDelegate)
      Sets a function which will be used to build context menu for geometries.
    • addPointClickListener

      Subscription addPointClickListener(Consumer<CanvasLayer.Point.ClickEvent> listener)
      Registers a new point click listener. Listener will be receiving events from all points on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPointRightClickListener

      Subscription addPointRightClickListener(Consumer<CanvasLayer.Point.RightClickEvent> listener)
      Registers a new point right click listener. Listener will be receiving events from all points on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPointModifiedListener

      Subscription addPointModifiedListener(Consumer<CanvasLayer.Point.ModifiedEvent> listener)
      Registers a new point modified (drag end) listener. Listener will be receiving events from all points on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPolylineClickListener

      Subscription addPolylineClickListener(Consumer<CanvasLayer.Polyline.ClickEvent> listener)
      Registers a new polyline click listener. Listener will be receiving events from all polylines on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPolylineRightClickListener

      Subscription addPolylineRightClickListener(Consumer<CanvasLayer.Polyline.RightClickEvent> listener)
      Registers a new polyline right click listener. Listener will be receiving events from all polylines on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPolylineModifiedEvent

      Subscription addPolylineModifiedEvent(Consumer<CanvasLayer.Polyline.ModifiedEvent> listener)
      Registers a new polyline modified listener. Listener will be receiving events from all polylines on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPolygonClickListener

      Subscription addPolygonClickListener(Consumer<CanvasLayer.Polygon.ClickEvent> listener)
      Registers a new polygon click listener. Listener will be receiving events from all polygons on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPolygonRightClickListener

      Subscription addPolygonRightClickListener(Consumer<CanvasLayer.Polygon.RightClickEvent> listener)
      Registers a new polygon right click listener. Listener will be receiving events from all polygons on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source
    • addPolygonModifiedEvent

      Subscription addPolygonModifiedEvent(Consumer<CanvasLayer.Polygon.ModifiedEvent> listener)
      Registers a new polygon modified listener. Listener will be receiving events from all polygons on the canvas.
      Parameters:
      listener - the listener to be added
      Returns:
      a registration object for removing an event listener added to a source