public interface CanvasLayer extends 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
.
Modifier and Type | Interface and Description |
---|---|
static interface |
CanvasLayer.Geometry
A common interface for a wrapper encapsulating a vector geometry on the canvas
and providing an API to control it.
|
static interface |
CanvasLayer.Point
A wrapper class encapsulating
Point on the canvas. |
static interface |
CanvasLayer.Polygon
A wrapper class encapsulating
Polygon on the canvas. |
static interface |
CanvasLayer.Polyline
A wrapper class encapsulating
LineString on the canvas. |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ID |
Modifier and Type | Method and Description |
---|---|
CanvasLayer.Point |
addPoint(org.locationtech.jts.geom.Point point)
Adds a JTS point to the canvas.
|
io.jmix.core.common.event.Subscription |
addPointClickListener(java.util.function.Consumer<CanvasLayer.Point.ClickEvent> listener)
Registers a new point click listener.
|
io.jmix.core.common.event.Subscription |
addPointModifiedListener(java.util.function.Consumer<CanvasLayer.Point.ModifiedEvent> listener)
Registers a new point modified (drag end) listener.
|
io.jmix.core.common.event.Subscription |
addPointRightClickListener(java.util.function.Consumer<CanvasLayer.Point.RightClickEvent> listener)
Registers a new point right click listener.
|
CanvasLayer.Polygon |
addPolygon(org.locationtech.jts.geom.Polygon polygon)
Adds a JTS polygon to the canvas.
|
io.jmix.core.common.event.Subscription |
addPolygonClickListener(java.util.function.Consumer<CanvasLayer.Polygon.ClickEvent> listener)
Registers a new polygon click listener.
|
io.jmix.core.common.event.Subscription |
addPolygonModifiedEvent(java.util.function.Consumer<CanvasLayer.Polygon.ModifiedEvent> listener)
Registers a new polygon modified listener.
|
io.jmix.core.common.event.Subscription |
addPolygonRightClickListener(java.util.function.Consumer<CanvasLayer.Polygon.RightClickEvent> listener)
Registers a new polygon right click listener.
|
CanvasLayer.Polyline |
addPolyline(org.locationtech.jts.geom.LineString polyline)
Adds a JTS linestring to the canvas.
|
io.jmix.core.common.event.Subscription |
addPolylineClickListener(java.util.function.Consumer<CanvasLayer.Polyline.ClickEvent> listener)
Registers a new polyline click listener.
|
io.jmix.core.common.event.Subscription |
addPolylineModifiedEvent(java.util.function.Consumer<CanvasLayer.Polyline.ModifiedEvent> listener)
Registers a new polyline modified listener.
|
io.jmix.core.common.event.Subscription |
addPolylineRightClickListener(java.util.function.Consumer<CanvasLayer.Polyline.RightClickEvent> listener)
Registers a new polyline right click listener.
|
void |
cancelDrawing()
Cancels the drawing mode.
|
void |
clear()
Removes all geometries from the canvas.
|
void |
drawPoint(java.util.function.Consumer<CanvasLayer.Point> afterPointDrawnAction)
Activates the point drawing mode.
|
void |
drawPolygon(java.util.function.Consumer<CanvasLayer.Polygon> afterPolygonDrawnAction)
Activates the polygon drawing mode.
|
void |
drawPolyline(java.util.function.Consumer<CanvasLayer.Polyline> afterPolylineDrawnAction)
Activates the polyline drawing mode.
|
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.
|
getId, getMaxZoom, getMinZoom, isEditable, isVisible, refresh, setEditable, setMaxZoom, setMinZoom, setVisible
static final java.lang.String ID
CanvasLayer.Point addPoint(org.locationtech.jts.geom.Point point)
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.
point
- JTS pointCanvasLayer.Polyline addPolyline(org.locationtech.jts.geom.LineString polyline)
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.
polyline
- JTS linestringCanvasLayer.Polygon addPolygon(org.locationtech.jts.geom.Polygon polygon)
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.
polygon
- JTS polygonvoid removePoint(CanvasLayer.Point point)
point
- canvas pointvoid removePolyline(CanvasLayer.Polyline polyline)
polyline
- canvas polylinevoid removePolygon(CanvasLayer.Polygon polygon)
polygon
- canvas polygonvoid clear()
void drawPoint(java.util.function.Consumer<CanvasLayer.Point> afterPointDrawnAction)
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
.
afterPointDrawnAction
- consumer that takes drawn CanvasLayer.Point
as an argumentvoid drawPolyline(java.util.function.Consumer<CanvasLayer.Polyline> afterPolylineDrawnAction)
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
.
afterPolylineDrawnAction
- consumer that takes drawn CanvasLayer.Polyline
as an argumentvoid drawPolygon(java.util.function.Consumer<CanvasLayer.Polygon> afterPolygonDrawnAction)
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
.
afterPolygonDrawnAction
- consumer that takes drawn CanvasLayer.Polygon
as an argumentvoid cancelDrawing()
io.jmix.core.common.event.Subscription addPointClickListener(java.util.function.Consumer<CanvasLayer.Point.ClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPointRightClickListener(java.util.function.Consumer<CanvasLayer.Point.RightClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPointModifiedListener(java.util.function.Consumer<CanvasLayer.Point.ModifiedEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPolylineClickListener(java.util.function.Consumer<CanvasLayer.Polyline.ClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPolylineRightClickListener(java.util.function.Consumer<CanvasLayer.Polyline.RightClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPolylineModifiedEvent(java.util.function.Consumer<CanvasLayer.Polyline.ModifiedEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPolygonClickListener(java.util.function.Consumer<CanvasLayer.Polygon.ClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPolygonRightClickListener(java.util.function.Consumer<CanvasLayer.Polygon.RightClickEvent> listener)
listener
- the listener to be addedio.jmix.core.common.event.Subscription addPolygonModifiedEvent(java.util.function.Consumer<CanvasLayer.Polygon.ModifiedEvent> listener)
listener
- the listener to be added