兰保明

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
View Code
 1   <Grid.ColumnDefinitions>
2 <ColumnDefinition />
3 <ColumnDefinition />
4 </Grid.ColumnDefinitions>
5
6 <esri:Map x:Name="MyMap" Extent="-9270434.248,5246977.326,-9269261.417,5247569.712"
7 Grid.Column="0">
8 <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
9 Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
10 <esri:ArcGISDynamicMapServiceLayer ID="BloomfieldHillsMichigan"
11 Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"/>
12 </esri:Map>
13
14 <Grid Margin="10" Grid.Column="1" Background="White" VerticalAlignment="Stretch">
15 <ScrollViewer>
16 <TextBlock x:Name="PropertiesTextBlock" Text="Initializing..." />
17 </ScrollViewer>
18 </Grid>
19
20
21 public partial class ShowMapProperties : UserControl
22 {
23 public ShowMapProperties()
24 {
25 InitializeComponent();
26
27 MyMap.Layers.LayersInitialized += Layers_LayersInitialized;
28 }
29
30 void Layers_LayersInitialized(object sender, System.EventArgs args)
31 {
32 StringBuilder sb = new StringBuilder();
33
34 sb.AppendLine(string.Format("Spatial Reference: {0}", MyMap.SpatialReference.WKT != null ? MyMap.SpatialReference.WKT : MyMap.SpatialReference.WKID.ToString()));
35 sb.AppendLine(string.Format("Minimum Resolution: {0}", MyMap.MinimumResolution));
36 sb.AppendLine(string.Format("Maximum Resolution: {0}", MyMap.MaximumResolution));
37 sb.AppendLine(string.Format("Width (pixels): {0}", MyMap.ActualWidth));
38 sb.AppendLine(string.Format("Height (pixels): {0}", MyMap.ActualHeight));
39 sb.AppendLine();
40 sb.AppendLine(string.Format("---Map Layers ({0})---", MyMap.Layers.Count));
41 sb.AppendLine();
42
43 foreach (Layer layer in MyMap.Layers)
44 {
45 sb.AppendLine(string.Format("ID: {0}", layer.ID));
46 sb.AppendLine(string.Format("Type: {0}", layer.GetType().ToString()));
47 sb.AppendLine(string.Format("Visibilty : {0}", layer.Visible));
48 sb.AppendLine(string.Format("Opacity : {0}", layer.Opacity));
49 if (layer is ArcGISDynamicMapServiceLayer)
50 {
51 ArcGISDynamicMapServiceLayer dynLayer = layer as ArcGISDynamicMapServiceLayer;
52 sb.AppendLine(string.Format("\t---Layers ({0})---", dynLayer.Layers.Length));
53 foreach (LayerInfo layerinfo in dynLayer.Layers)
54 {
55 sb.AppendLine(string.Format("\tID: {0}", layerinfo.ID));
56 sb.AppendLine(string.Format("\tName: {0}", layerinfo.Name));
57 sb.AppendLine(string.Format("\tDefault Visibility: {0}", layerinfo.DefaultVisibility));
58
59 sb.AppendLine(string.Format("\tMinimum Scale: {0}", layerinfo.MinScale));
60 sb.AppendLine(string.Format("\tMaximum Scale: {0}", layerinfo.MaxScale));
61 if (layerinfo.SubLayerIds != null)
62 sb.AppendLine(string.Format("\tSubLayer IDs: {0}", layerinfo.SubLayerIds.ToString()));
63 sb.AppendLine();
64 }
65 }
66 if (layer is ArcGISTiledMapServiceLayer)
67 {
68 ArcGISTiledMapServiceLayer tiledLayer = layer as ArcGISTiledMapServiceLayer;
69 TileInfo ti = tiledLayer.TileInfo;
70 sb.AppendLine("Levels and Resolution :");
71 for (int i = 0; i < ti.Lods.Length; i++)
72 {
73 sb.Append(string.Format("Level: {0}\t \t Resolution: {1}\r", i, ti.Lods[i].Resolution));
74 }
75 }
76 sb.AppendLine();
77 }
78
79 PropertiesTextBlock.Text = sb.ToString();

posted on 2011-07-27 09:20  兰保明  阅读(334)  评论(0编辑  收藏  举报