This guide explains how you can interactively create features on a Map, and integrate this capability in an IControllerIControllerIController.

Overview

You start the process of interactive feature creation by sending input eventsinput eventsinput events to a creatorcreatorcreator. A feature creatorfeature creatorfeature creator creates the feature, and a geometry creatorgeometry creatorgeometry creator creates its geometry. The feature creator can convertconvertconvert the created geometries to a feature, and addsaddsadds them to the model.

Programmatically creating geometries

If you want to create geometries through the API instead of creating them interactively on the map, see the related article on geometries

Configuring feature creation

To configure feature creation, you can use these classes:

Integrating a creator with a controller

You can use the Creator class as a part of an IControllerIControllerIController implementation. To integrate the feature creator:

  • Delegate the input eventsinput eventsinput events. The creator 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, a creator can ignore mouse drag events, and use only mouse moves and click events. The controller can then still use the drag events to navigate the map.

  • Add the preview layerpreview layerpreview layer to the controller’s layer listlayer listlayer list. You must do that so that the map can visualize a preview of the created feature.

Setting line creation modes to define input events

The line creation modeline creation modeline creation mode defines how input events generate a line by placing points in sequence.

The supported line creation modes are:

You can configure the line creation mode of the following creators:

Constraining geometries during creation

The creation API supports geometry constraints out-of-the-box. You can use most IGeometryCreatorIGeometryCreatorIGeometryCreator implementations to configure a constraint to apply during creation. See the related article for more information.

Examples of customizations

The tutorial Creating a custom geometry creator shows how you can implement your own geometry creator.