Visual Basic (Declaration) | |
---|---|
Public NotInheritable Class Map Inherits System.Windows.Controls.Control |
C# | |
---|---|
public sealed class Map : System.Windows.Controls.Control |
The Map allows the user to zoom and pan around one or more map service layers placed on top of each other.
Navigation: The map has the following default navigation options:
User Action | Description | Platform |
---|---|---|
Left Mouse Button Drag | Pans the map. | Silverlight WPF |
Left Mouse Double-click | Zooms the map in the amount specified in ZoomFactor around the map cursor. | Silverlight WPF |
Left Mouse Double-click + Shift Key | Zooms the map out the amount specified in ZoomFactor around the map cursor. | Silverlight WPF |
Left Mouse Wheel | Zooms the map in or out the amount specified in ZoomFactor around the map cursor. | Silverlight WPF |
Left mouse + Sthif Key + Drag | Drags a zoom box and zooms to the box. | Silverlight WPF |
Left Mouse + Shift Key + Ctrl Key + Drag | Drags a zoom box and zooms out around the box. | Silverlight WPF |
Up Arrow Key | Pans the map up. | Silverlight WPF |
Down Arrow Key | Pans the map down. | Silverlight WPF |
Left Arrow Key | Pans the map to the left. | Silverlight WPF |
Right Arrow Key | Pans the map to the right. | Silverlight WPF |
+ Key | Zooms in the amount specified in ZoomFactor around the map center. | Silverlight WPF |
- Key | Zooms out the amount specified in ZoomFactor around the map center. | Silverlight WPF |
Pan/Drag Gesture |
Pans in the direction the finger is moved. | Silverlight WPF Windows Phone |
Pinch Gesture |
Zooms in. | Silverlight WPF Windows Phone |
Stretch Gesture |
Zooms out. | Silverlight WPF Windows Phone |
Double-tap Gesture |
Zooms in one zoom factor. The zoom factor is defined by the ZoomFactor property. | Silverlight WPF Windows Phone |
Flick Gesture |
Pans in the direction of the flick and slowly comes to a stop. | Silverlight WPF Windows Phone |
If the map contains any tiled layers, the map will by default only allow you to zoom out and in to the range of the tiled cache resolution. However this value can be overridden explictly by setting the MinimumResolution and MaximumResolution properties on the map. These values can also be used to limit how far the user can zoom in or out. If no tiled layers are present, these values defaults to System.Double.Epsilon and System.Double.MaxValue.
In order to navigate in a map via the mouse scroll wheel when a Silverlight application first starts, it is required that the end user clicks somewhere in the application for the Silverlight application to have focus. The first time a Silverlight application starts there is no initial focus set; by clicking somewhere in the Silverlight application the application obtains focus.
Layers: The control supports a set of base layer types that are supported for display within a map. These are:
Command | Description |
---|---|
TiledMapServiceLayer | Abstract layer type. Displays cached images arranged as a set of image tiles. See ArcGISTiledMapServiceLayer |
DynamicLayer | Abstract layer type. Displays non-cached images generated generated based on an image size and map extent. See ArcGISDynamicMapServiceLayer, ArcGISImageServiceLayer |
GraphicsLayer | Displays Graphics rendered on the client using a custom symbology and allows for user interaction (click, select, mouse over etc). Also see FeatureLayer |
ElementLayer | Allows the user to place any System.Windows.UIElement relative to a point or scaled to an extent on the map. |
Spatial Reference: The Map's spatial reference is determined by the first layer in the map that has this property set. However, it can be overridden by explicitly setting the Extent property with an envelope that has a SpatialReference defined. This has to be done before any layers will be initalized by the map. Once the spatial reference of a map has been set and the layers has loaded, the spatial reference can no longer be changed. If you need to change spatial reference on the fly, you can instead create a new map instance, move the layers to this map, and replace the previous map instance. Also note that tiled layers does not support reprojection, and will not be displayed if the Map's SpatialReference does not match the spatial reference of the tiled layer.
Map Scale and Resolution: The map is scale agnostic, meaning that it doesn't deal with the scale of the map at any given point. Instead it exposes a resolution value that tells you how many map units one pixel represents. This has the benefit of being agnostic to the DPI (dots per inches) settings of your screen - something that a scale value is not. A large screen has a different scale than a smaller screen with the same amount of pixels across, and therefore the scale can be misleading when viewing the same map on two different screen, like for instance on a projector screen and a laptop.
If you were to assume a DPI setting on your screen (96dpi is a common used value) and you know the units used in your map's SpatialReference, you can calculate the scale of your map.
Map scale = 1 : (ScreenRes pixels/inch * 39.37 inches/meter * (Map.Resolution * conversionFactorToMeters))So if your map units are in meters and you have a screen resolution of 96dpi the current map scale is:
Map scale = 1 : (96dpi * 39.37 inches/meter * (Map.Resolution * 1))
Creating a map instance with two layers and a startup extent:
<esri:Map x:Name="MyMap" Extent="-120,20,-90,60">
<esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer" Opacity="0.6"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/>
</esri:Map
Creating a map instance with a pre-defined spatial reference:
<esri:Map x:Name="MyMap">
<esri:Map.Extent>
<esri:Envelope XMin="661140" YMin="-1420246" XMax="3015668" YMax="1594451" >
<esri:Envelope.SpatialReference>
<esri:SpatialReference WKID="26777"/>
</esri:Envelope.SpatialReference>
</esri:Envelope>
</esri:Map.Extent>
<esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer1"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"/>
<esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer2"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer"/>
</esri:Map>
System.Object
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
ESRI.ArcGIS.Client.Map
Target Platforms: Windows Vista, Windows 7