[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Collapse]Map Control
   [Expand]Getting Started
   [Expand]Coordinate Systems
   [Expand]Map Image Data
   [Expand]GIS Data
   [Expand]Vector Data
   [Expand]Visual Elements
   [Collapse]End-User Features
     Select and Highlight Map Items
     Search Panel
     Map Editor
     Mini Map
     Printing and Exporting
   [Expand]Product Information
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Map Editor

The Map Editor allows users to create and modify map items. They can rotate map items and resize them with the sizing and rotation handles, and relocate items on the map surface. The Map Editor's active mode determines the actions a user can perform. The editor panel buttons allow users to switch between Default, Transform, Edit and Create modes.

Expanded Map Editor Panel

You can set the MapEditor.ShowEditorPanel property to true at design time in the Properties window to display the Map Editor's panel.

Use the code below to show the Editor's panel at runtime.

The following table lists the API members that allow you to manage the Map Editor's settings:

Member Description
MapControl.MapEditor Returns the Map Editor to configure its options.
MapEditor The Map Editor that allows end users to edit map Vector Items.
MapEditor.ShowEditorPanel Specifies whether the map editor's panel is displayed.
VectorItemsLayer.AllowEditItems Gets or sets the value that specifies whether a user can edit the map vector layer's items.

The Map Editor's panel contains the following buttons:

Button Description Visibility
"Undo" Cancels the last action. EditorPanelOptions.ShowUndoRedoButtons
"Redo" Restores the last canceled action. EditorPanelOptions.ShowUndoRedoButtons
"Default" Enables Default mode. EditorPanelOptions.ShowDefaultModeButton
"Transform" Activates Transform mode. EditorPanelOptions.ShowTransformModeButton
"Edit" Turns on Edit mode. EditorPanelOptions.ShowEditModeButton
"Add Pushpin" Enables "Create Pushpin" mode to create MapPushpin items. EditorPanelOptions.ShowAddPushpinButton
"Add Path" Enables "Create Path" mode to create MapPath items. EditorPanelOptions.ShowAddPathButton
"Add Polyline" Activates "Create Polyline" mode to create MapPolyline items. EditorPanelOptions.ShowAddPolylineButton
"Add Dot" Enables "Create Dot" mode to create MapDot items. EditorPanelOptions.ShowAddDotButton
"Add Ellipse" Enables "Create Ellipse" mode to create MapEllipse items. EditorPanelOptions.ShowAddEllipseButton
"Add Rectangle" Turns on "Create Rectangle" mode to create MapRectangle items. EditorPanelOptions.ShowAddRectangleButton
"Add Line" Enables "Create Line" mode to create MapLine items. EditorPanelOptions.ShowAddLineButton

Expanded Map Editor Modes

The Map editor provides the following modes that define the available map edit actions:

Default Mode

You can only view the map and cannot edit, create and transform map items in Default mode. You can use the button to enable this mode.

Transform Mode

Select to enable Transform mode. Use the sizing and rotation handles that appear when you select items to resize and rotate the selected map items, and drag items to move them.

Use the MapEditor.SetTransformMode method to enable the Transform mode from code. Refer to the Map Editor API section for more information.

Edit Mode

Use the button to enable Edit mode. In this mode, you can move, add, and remove item vertices to change vector map shapes. To edit a map item in this mode, select an item to display its points and perform one of the following actions:

Action Animation Description
Move vertices Drag a map shape's point to a new position to relocate the point.
Add vertices To add a new vertex, hover the mouse pointer over the item's edge between two points and click where you want to insert a new vertex.
Remove vertices Double-click a map shape's point to remove it.

Note that you can only edit the following map vector items:

Use the MapEditor.SetEditMode method to enable Edit mode when you implement a custom map editor UI. Refer to the Map Editor API section for more information.

Create Mode

Create mode allows you to add new items to the map. Use the following buttons on the Editor panel to enable the Create mode:

Click the location where you want to add dots and pushpins.

To add rectangles and ellipses, click a map to add start point. Drag the pointer, click again to add an end point and finish item.

To create a complex map item, sequentially add points to form a map item. Press Enter to finish the item. The following animation shows how to create a map path:

Use the MapEditor.SetCreateMode method to enable the Create mode when you develop a custom map editor UI. Refer to the Map Editor API section for more information.

Expanded Map Editor API

This section describes the Map Editor's API that allows you to design a custom map edit UI.

Switch modes

You can use the methods below to change a Map Editor mode programmatically:

The table below lists API members that allow you to manage the Map Editor's modes.

Member Description
MapEditor.SetTransformMode Enables Transformation mode. This mode allows you to apply the specified transformation to the map items.
MapItemTransform Lists transformations that can be applied to a map item.
MapEditor.SetEditMode Enables Edit mode. This mode allows end users to edit map items.
MapEditor.SetCreateMode Enables Create mode. This mode allows end users to create items of the specified type.
CreatableMapItemKind Lists the map item types that the Map Editor can create while it is in the Create mode.
MapEditor.ResetEditMode Resets the Map Editor's edit mode.

Handle the MapItemCreating event

The MapEditor.MapItemCreating event is raised when a user creates a vector item on the map. You can handle this event to customize map item options before it is drawn. For example, the code below shows you how to draw a map item with a specified color.

If necessary, use the MapItemCreatingEventArgs.Cancel property to interrupt a map item's creation.

Handle the MapItemEditing and MapItemEdited events

The Map Editor provides two events that allow you to track users' actions while they edit map items:

Active Layer

Use the MapEditor.ActiveLayer property to obtain the map vector layer that stores newly created items. See the code below for details on how to export active layer items to a KML file.

Edit Map Items

You can update, insert, or remove points to edit a map item's contours. For example, the following code shows how to update map polygon point coordinates:

The following table lists members that allow you to edit a map item's contours:

Member Description
MapEditor.UpdateItemPoint Updates a map item's contour point coordinates.
MapEditor.InsertItemPoint Inserts a new point to a map item's contour.
MapEditor.RemoveItemPoint Removes a map item's contour point.

Transform Map Items

You can apply geometric transformations such as rotation, translation and scaling to map items. The code translates map items:

The following table lists methods that allow you to transform map items:

Method Description
MapEditor.TranslateItems Translates items at the specified offset.
MapEditor.ScaleItems Scales the map items.
MapEditor.RotateItems Rotates the items at the specified angle.

Undo/Redo Prior Operations

The Map control stores all user edit actions. The MapEditor.Undo method allows you to undo the most recent action, and the MapEditor.Redo method restores the last canceled action. You should check whether these operations can be performed via the MapEditor.CanUndo/MapEditor.CanRedo properties before you call the Undo/Redo methods. Use the MapEditor.ClearSavedActions method to clear the saved actions collection. The Map control does not save user actions if you set the MapEditor.AllowSaveActions property to false.

Simplify Map Shapes

The Map control allows you to simplify detailed Vector Items to reduce memory consumption and enhance a map's responsiveness. Use the MapEditor.SimplifyItems method to decrease the number of map shape vertices. The Map control changes the existing vertex positions and removes unnecessary vertices. The resulting shape's resolution depends on the tolerance parameter passed with SimplifyItems. You can use the Undo operation to cancel this action.

The following example shows how to simplify items and use the TrackBarControl (see TrackBarControl) to change the tolerance:

You can use the ShapeSimplifierBase.Simplify(IEnumerable<MapItem>, Double) (see ShapeSimplifierBase.Simplify) method to simplify items before they are displayed on a layer.

Geometric Measurements

The GeoUtils (see GeoUtils) class exposes methods that measure geometric values based on geographical coordinates. You can use this information to develop map measurement instruments (for example, a map ruler) in a custom map editor.

Expanded See Also

Is this topic helpful?​​​​​​​