This guide explains how you can interactively edit features on a Map, and integrate this capability in an
to edit actions that are applied to a
of features. For these features, the editor
visualizes a set of
The handles are linked to edit actions that perform the actual
Programmatically creating geometries
link: If you want to edit geometries through the API instead of editing them interactively on the map, see the related article on geometries.
To understand how features or geometries are edited, a few concepts need to be explained.
To make it easier to observe the changes that are happening to an edited feature or geometry, the following classes are used in the edit API:
The classes store a Feature or Geometry that can change during editing. It allows you to get the current state, and observe changes to the Feature or Geometry. This for example allows you to update the handles of an object that is being edited.
IEditHandle is a
component on the map that triggers concrete edit actions based on
An example is a point handle that is visualized as an icon, and that you can drag around or click on.
An edit handle triggers a change to the feature or geometry by notifying that it has changed. A point handle will for example
send a notification that it has moved. Based on that notification, the
can modify a feature or geometry.
TranslateEditHandle: This handle is either not visualized, or visualized by a
shadow geometry. It allows you to drag it around, and translate an entire geometry. It uses
ITranslateEditActionto signal that an action is performed.
This collection must update its own handles whenever the edited object changes. The edited object can change in two cases:
IGeometryHandlesProvider can create an
for a given feature or geometry. These classes are typically stateless, and can be reused for more than one feature or
PointHandlesProvider: provides handles to edit Point geometries
PolylineHandlesProvider: provides handles to edit Polyline geometries
PolylineRingHandlesProvider: provides handles to edit PolylineRing geometries
PatchHandlesProvider: provides handles to edit patches. This class doesn’t provide any handles itself, but it asks an other
IGeometryHandlesProviderto provide handles for its base geometry, for example a
The following diagram shows the most common interactions between the different concepts:
Handle interaction is wired together using callbacks and observers:
IEditHandleimplementations typically use an action to notify
IEditHandlesthat they have been modified. Based on this callback, the
IEditHandlesimplementation can modify the feature or geometry. An example is
IPointEditActionto communicate that the handle has been interacted with.
To configure feature editing, you can use these classes:
configure the edit candidatesused.
Configure the handlesused to edit a Feature.
Disableediting for a single feature
You can use the Editor class as a part of an
IController implementation. To integrate the feature
input events. The editor may or may not consume those events. Based on that information, the controller can decide to ignore the event, or use it for something else. For example, an editor can ignore mouse drag events when there is no Feature under the mouse cursor. The controller can still use these events to navigate the map, though.
The following articles and tutorials give examples of how you can customize the edit behavior:
This tutorial shows you how to customize existing handles provider.
This tutorial shows you how you can extra handles to an existing handles provider.
This tutorial shows how you can implement your own handles provider.