Custom map navigation commands


Purpose
This topic provides a set of sample PanZoom commands and tools that can be used in conjunction with the MapControl, PageLayoutControl, and ToolbarControl. It is assumed you have previous experience in creating custom tools and commands.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Build the project.
  2. Do one of the following: a) Add the commands to the ToolbarControl programmatically using the IToolbarControl.AddItem method; b) Use the commands directly with the MapControl or PageLayoutControl programmatically by creating a new instance of a command and passing the MapControl or PageLayoutControl to its OnCreate event; c) Add the commands interactively to the ToolbarControl by clicking the Add from File button in the ToolbarControl's Customizing dialog box (available through the property pages) and browsing to the *.tlb file; or d) Add the commands interactively to the ToolbarControl by dragging them from the Sample_Pan[_VBNET]/Zoom category in the ToolbarControl's Customizing dialog box.

Additional information

This sample uses the following:
  • FixedZoomIn and FixedZoomOut commands—The IEnvelope.Expand method is used to scale the size of the IActiveView.Extent property to zoom in and out on the FocusMap by a fixed amount.
  • ZoomIn and ZoomOut tools—An INewEnvelopeFeedback object is used to track IEnvelope in the OnMouseDown, OnMouseMove, and OnMouseUp events, which is then set to the IActiveView.Extent property of the FocusMap. If the Escape (Esc) key is pressed, the track is cancelled.
  • FullExtent command—The IActiveView.Extent property is set to the FullExtent of all the data layers present in the FocusMap.
  • GoBackToPrevious (UndoExt) and GoToNextExtent (RedoExt) commands—The IActiveView.Extent property is set to the previous and next extent held in the IActiveView.ExtentStack property of the FocusMap.
  • Pan tool—The IScreenDisplay interface PanStart and PanMoveTo methods are used in the OnMouseDown and OnMouseMove events to start and move a pan, and the IScreenDisplay.PanStop method is used in the OnMouseUp event to set the IActiveView.Extent property of the FocusMap to the new visible bounds.
  • PanDown, PanLeft, PanUp, and PanRight commands—The IActiveView.Extent property of the FocusMap is centered on a point to the left, right, top, or bottom of the current extent's center.


AssemblyInfo.cs Assembly information.
FixedZoomIn.cs Class file.
FixedZoomOut.cs Class file.
FullExtent.cs Class file.
GoBackToPreviousExtent.cs Class file.
GoToNextExtent.cs Class file.
Pan.cs Class file.
PanDown.cs Class file.
PanLeft.cs Class file.
PanRight.cs Class file.
PanUp.cs Class file.
ZoomIn.cs Class file.
ZoomOut.cs Class file.
Download the C# files
AssemblyInfo.vb Assembly information.
FixedZoomIn.vb Form file.
FixedZoomOut.vb Class file.
FullExtent.vb Class file.
GoBackToPreviousExtent.vb Class file.
GoToNextExtent.vb Class file.
Pan.vb Class file.
PanDown.vb Class file.
PanLeft.vb Class file.
PanRight.vb Class file.
PanUp.vb Class file.
ZoomIn.vb Class file.
ZoomOut.vb Class file.
Download the VB.NET files

Download the files for all languages

See Also:

HookHelper Class
IHookHelper Interface




Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced