Working with the Map

The MapWidget class has a Map property that exposes the control that is used to display geographical information, generally taking up the full extent of the map widget. This Map is an instance of the ESRI.ArcGIS.Client.Map class, which is part of the ArcGIS Runtime SDK for WPF that the Operations Center is built on.

The Map will contain all the layers that are drawn in the map; some of these layers may provide a data source to the application, depending on the settings chosen by the operational view author in the Configure Map dialog box.

Treat the ESRI.ArcGIS.Client.Map as read-only

It is recommended to treat the Map of each map widget as read-only. Properties of the map such as the Extent and SpatialReference can be found. The layers in the map can be retrieved, and properties such as the URL and popup information can be found; features within feature layers can be retrieved, along with information about the features such as their geometry and attributes.

This recommendation is in place to preserve normal running of the application. For example, the application relies on data sources configured within the map to remain in the map; changing or removing a layer that provides a data source to the application may cause an application error.

Exceptions

A number of supported exceptions to this read-only recommendation are listed below; these exceptions will change properties or content of the map:

  • Navigation: Navigation of the Map, for example by changing the Extent property, or using the Pan, Zoom or ZoomTo methods. Note that if the Follow tool is active in the map, this may cause a suspension in following behaviour; the Follow tool will change to allow the end user to resume or cancel the Follow, this cannot be performed programmatically.
  • Adding temporary graphics: Adding temporary graphics to the map by adding a new GraphicsLayer and adding Graphics to the new layers. It is recommended to add the new graphics layer to the existing AcceleratedDisplayLayers collection in the map. Any graphics layers added to the map at run time will not be persisted if the map is saved. See the Adding temporary graphics topic for more information.

Accelerated map display and the AcceleratedDisplayLayers collection

The application uses the accelerated map display that is part of the ArcGIS Runtime SDK for WPF, a new high-performance DirectX map rendering engine, in order to achieve performance benefits with large numbers of graphics that are frequently updated. All child layers in the map are contained in a single AcceleratedDisplayLayers collection.

Note: Again, the recommendation to treat the Map as read-only applies; the accelerated display should not be disabled on a Map as this may cause an application error.

How To: Get the AcceleratedDisplayLayers collection and its child layers

  1. Find the MapWidget you want to work with. For example, in a widget that implements IMapConsumer, use the IMapConsumer.Id to identify the map.
  2. From the Layers property of the MapWidget.Map, get the AcceleratedDisplayLayers collection. There will be only one instance of this type.
  3. Use the ChildLayers property of the AcceleratedDisplayLayers collection to iterate through the child layers. For example, the code below finds all FeatureLayer instances and gets the DisplayName property.

AcceleratedDisplayLayers example code

MapWidget widget = OperationsCenter.Instance.Widgets.FirstOrDefault(w => w.Id == mapWidgetId) as MapWidget;
 if (widget != null)
 {
   client.AcceleratedDisplayLayers aclyrs = widget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
   foreach (client.FeatureLayer fl in aclyrs.ChildLayers.OfType<client.FeatureLayer>())
   {
     System.Diagnostics.Trace.WriteLine(fl.DisplayName);
   }
}

AcceleratedDisplayLayers example code

Dim widget As MapWidget = OperationsCenter.Instance.Widgets.FirstOrDefault(Function(w) w.Id = mapWidgetId)
If (Not Widget Is Nothing) Then
  Dim acLyrs As client.AcceleratedDisplayLayers = widget.Map.Layers.FirstOrDefault(Function(lyr) TypeOf lyr Is client.AcceleratedDisplayLayers)
  For Each fl As client.FeatureLayer In acLyrs.ChildLayers.OfType(Of client.FeatureLayer)()
    System.Diagnostics.Trace.WriteLine(fl.DisplayName)
  Next
End If
1/27/2015