A project can contain multiple maps, either 2D or 3D, and each defines the collection of layers that make up that map. A map view is simply a view of a map. Map views are the primary interface used to display, navigate, select, identify, and edit data in a 2D or 3D map. The MapView class provides properties and methods to navigate and interact with layers in the map. The map being visualized in the view can be accessed via the Map property.
There can be multiple map views open at a given time, but there can only be one active map view. The active map view will set the context for the ribbon and many of the dock panes in the application. For example, the map Contents pane will reflect the layers of the active map view's map. The instance of the active map view can be accessed via the static the Active property. The active property will return null if there is no active map view. This is useful when writing commands designed to interact with the active map.
The map view also provides the context for the selected items in the Contents pane. For example, the GetSelectedLayers method returns the collection of layers that are currently selected in the Contents pane. This context is used to determine which contextual tabs to show, for example, when one or more feature layers are selected, the Feature Layer tab group will display, and the commands will act on the selected feature layers. This is useful when writing commands to work with the selected items in the Contents pane.
public void RotateView(double heading) { //Get the active map view. var mapView = MapView.Active; if (mapView == null) return; //Get the camera for the view, adjust the heading and zoom to the new camera position. var camera = mapView.Camera; camera.Heading = heading; mapView.ZoomToAsync(camera, TimeSpan.Zero); }
System.Object
ArcGIS.Desktop.Mapping.MapView
Target Platforms: Windows 10, Windows 8.1, Windows 7