Interface CanvasLayer
- All Superinterfaces:
Layer
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
.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A common interface for a wrapper encapsulating a vector geometry on the canvas and providing an API to control it.static interface
A wrapper class encapsulatingPoint
on the canvas.static interface
A wrapper class encapsulatingPolygon
on the canvas.static interface
A wrapper class encapsulatingLineString
on the canvas. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddPoint
(org.locationtech.jts.geom.Point point) Adds a JTS point to the canvas.Registers a new point click listener.Registers a new point modified (drag end) listener.Registers a new point right click listener.addPolygon
(org.locationtech.jts.geom.Polygon polygon) Adds a JTS polygon to the canvas.Registers a new polygon click listener.Registers a new polygon modified listener.Registers a new polygon right click listener.addPolyline
(org.locationtech.jts.geom.LineString polyline) Adds a JTS linestring to the canvas.Registers a new polyline click listener.Registers a new polyline modified listener.Registers a new polyline right click listener.void
Cancels the drawing mode.void
clear()
Removes all geometries from the canvas.void
drawPoint
(Consumer<CanvasLayer.Point> afterPointDrawnAction) Activates the point drawing mode.void
drawPolygon
(Consumer<CanvasLayer.Polygon> afterPolygonDrawnAction) Activates the polygon drawing mode.void
drawPolyline
(Consumer<CanvasLayer.Polyline> afterPolylineDrawnAction) Activates the polyline drawing mode.Returns a function which is used to build context menu for geometries.void
removePoint
(CanvasLayer.Point point) Removes a point from the canvas.void
removePolygon
(CanvasLayer.Polygon polygon) Removes a polygon from the canvas.void
removePolyline
(CanvasLayer.Polyline polyline) Removes a polyline from the canvas.void
setContextMenuDelegate
(Function<ContextMenuInvocationContext, ContextMenu> contextMenuDelegate) Sets a function which will be used to build context menu for geometries.Methods inherited from interface io.jmix.mapsui.component.layer.Layer
getId, getMaxZoom, getMinZoom, isEditable, isVisible, refresh, setEditable, setMaxZoom, setMinZoom, setVisible
-
Field Details
-
ID
- See Also:
-
-
Method Details
-
addPoint
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 toremovePoint(Point)
method to remove the point from the canvas.- Parameters:
point
- JTS point- Returns:
- canvas point
-
addPolyline
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 toremovePolyline(Polyline)
method to remove the polyline from the canvas.- Parameters:
polyline
- JTS linestring- Returns:
- canvas polyline
-
addPolygon
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 toremovePolygon(Polygon)
method to remove the polygon from the canvas.- Parameters:
polygon
- JTS polygon- Returns:
- canvas polygon
-
removePoint
Removes a point from the canvas.- Parameters:
point
- canvas point
-
removePolyline
Removes a polyline from the canvas.- Parameters:
polyline
- canvas polyline
-
removePolygon
Removes a polygon from the canvas.- Parameters:
polygon
- canvas polygon
-
clear
void clear()Removes all geometries from the canvas. -
drawPoint
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 drawnCanvasLayer.Point
as an argument
-
drawPolyline
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 drawnCanvasLayer.Polyline
as an argument
-
drawPolygon
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 drawnCanvasLayer.Polygon
as an argument
-
cancelDrawing
void cancelDrawing()Cancels the drawing mode. -
getContextMenuDelegate
Function<ContextMenuInvocationContext,ContextMenu> getContextMenuDelegate()Returns a function which is used to build context menu for geometries. -
setContextMenuDelegate
Sets a function which will be used to build context menu for geometries. -
addPointClickListener
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
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
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
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
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
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
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
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
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
-