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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA common interface for a wrapper encapsulating a vector geometry on the canvas and providing an API to control it.static interfaceA wrapper class encapsulatingPointon the canvas.static interfaceA wrapper class encapsulatingPolygonon the canvas.static interfaceA wrapper class encapsulatingLineStringon the canvas. -
Field Summary
Fields -
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.voidCancels the drawing mode.voidclear()Removes all geometries from the canvas.voiddrawPoint(Consumer<CanvasLayer.Point> afterPointDrawnAction) Activates the point drawing mode.voiddrawPolygon(Consumer<CanvasLayer.Polygon> afterPolygonDrawnAction) Activates the polygon drawing mode.voiddrawPolyline(Consumer<CanvasLayer.Polyline> afterPolylineDrawnAction) Activates the polyline drawing mode.voidremovePoint(CanvasLayer.Point point) Removes a point from the canvas.voidremovePolygon(CanvasLayer.Polygon polygon) Removes a polygon from the canvas.voidremovePolyline(CanvasLayer.Polyline polyline) Removes a polyline from the canvas.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.Pointwhich 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.Polylinewhich 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.Polygonwhich 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
afterPointDrawnActionis 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.Pointas an argument
-
drawPolyline
Activates the polyline drawing mode.After the polyline is drawn the
afterPolylineDrawnActionis 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.Polylineas an argument
-
drawPolygon
Activates the polygon drawing mode.After the polygon is drawn the
afterPolygonDrawnActionis 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.Polygonas an argument
-
cancelDrawing
void cancelDrawing()Cancels the drawing mode. -
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
-