显示地图属性

ContractedBlock.gif ExpandedBlockStart.gif 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();

转载于:https://www.cnblogs.com/lanbaoming/archive/2011/07/27/2117865.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值