关于地图显示级别的控制和各种比例尺的具体数值

        下面这个函数记录了各个比例尺的大小,以及可以利用地图比例尺的变化,控制某些图层的显示:

 1         /// <summary>
 2         /// 当地图 图幅发生改变时,比例尺 也会 发生 变化, 做出的事件响应
 3         /// </summary>
 4         /// <param name="sender"></param>
 5         /// <param name="e"></param>
 6         private void myMap_ExtentChanged(object sender, ExtentEventArgs e)
 7         {
 8             m_resl = new Dictionary<int, double>();
 9             m_resl.Add(1, 295497593.05875003);
10             m_resl.Add(2, 147748796.52937502);
11             m_resl.Add(3, 73874398.264687508);
12             m_resl.Add(4, 36937199.132343754);
13             m_resl.Add(5, 18468599.566171877);
14             m_resl.Add(6, 9234299.7830859385);
15             m_resl.Add(7, 4617149.8915429693);
16             m_resl.Add(8, 2308574.9457714846);
17             m_resl.Add(9, 1154287.4728857423);
18             m_resl.Add(10, 577143.73644287116);
19             m_resl.Add(11, 288571.86822143558);
20             m_resl.Add(12, 144285.93411071779);
21             m_resl.Add(13, 72142.967055358895);
22             m_resl.Add(14, 36071.483527679447);
23             m_resl.Add(15, 18035.741763839724);
24             m_resl.Add(16, 9017.8708819198619);
25             m_resl.Add(17, 4508.9354409599309);
26             m_resl.Add(18, 2254.4677204799655);
27             m_resl.Add(19, 1127.2338602399827);
28             m_resl.Add(20, 563.61693011999137);
29 
30             //////////////////////////////////////////////////////////////////////////
31             //比例尺较大时,规划图层才显示
32             if (this.myMap.Scale < m_resl[15])
33             {
34                 int i, n;
35                 n = MyLayerList.Layers.Count;
36 
37                 for (i = 0; i < n; i++)
38                 {
39                     if (MyLayerList.LayerItems[i].Visible)
40                     {
41                         //myMap.Layers[myMap.Layers.IndexOf(layer)].Visible = true;
42                         MyLayerList.Layers[i].Visible = true;
43                     }
44 
45                 }
46             }
47             //以下是不显示的情况
48             else
49             {
50                 int i, n;
51                 n = MyLayerList.Layers.Count;
52 
53                 for (i = 0; i < n; i++)
54                 {
55                     ILayer layer = MyLayerList.Layers[i];
56                     if (layer != null && layer.Visible)
57                     {
58                         //myMap.Layers[myMap.Layers.IndexOf(layer as GraphicsLayer)].Visible = false;
59                         MyLayerList.Layers[i].Visible = false;
60 
61                     }
62 
63                 }
64             }
65 
66 
67         }

 

posted @ 2014-06-07 18:29  DowTowne  阅读(957)  评论(0)    收藏  举报