天天看點

AE 中的查找與定位,以城市查找為例

在文本框輸入一個城市,在地圖上查找,當找到後讓mapcontrol自動跳轉到地圖上該點。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<code>IQueryFilter filter = </code><code>new</code> <code>QueryFilterClass();</code>

<code>filter.WhereClause = </code><code>" NAME='"</code><code>+城市名稱+</code><code>"'"</code><code>;</code>

<code>IFeatrueSel.SelectFeatures(filter, esriSelectionResultEnum.esriSelectionResultNew, </code><code>false</code><code>);</code>

<code>IFeatureCursor cursor = IFeatureLay.Search(filter, </code><code>false</code><code>);</code>

<code>IFeature feat = cursor.NextFeature();</code>

<code>if</code> <code>(feat != </code><code>null</code><code>)</code>

<code>{</code>

<code>    </code><code>//先清除地圖中被選中的要素</code>

<code>    </code><code>this</code><code>.axMapControl1.Map.ClearSelection();</code>

<code>    </code><code>IGeometry zdGeo = feat.Shape;</code>

<code>    </code><code>try</code>

<code>    </code><code>{</code>

<code>        </code><code>this</code><code>.axMapControl1.ActiveView.ExtentStack.Do(zdGeo.Envelope);</code>

<code>        </code><code>this</code><code>.axMapControl1.ActiveView.Extent = zdGeo.Envelope;</code>

<code>        </code><code>this</code><code>.axMapControl1.ActiveView.Refresh();</code>

<code>        </code><code>this</code><code>.axMapControl1.FlashShape(zdGeo, 2, 300, Type.Missing);</code>

<code>    </code><code>}</code>

<code>    </code><code>catch</code> <code>(Exception ex)</code>

<code>    </code><code>{      </code>

<code>        </code><code>return</code><code>;</code>

<code>}</code>

<code>System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);</code>

AE中将地圖頁面跳轉到指定坐标點

<code>Mappoint p=</code><code>new</code> <code>Mappoint();</code>

<code>p.x=已知點X坐标;</code>

<code>p.y=已知點Y坐标;</code>

<code>mapControl1.Extent.CenterAt(p);</code>

參考文章

沒有整理與歸納的知識,一文不值!高度概括與梳理的知識,才是自己真正的知識與技能。 永遠不要讓自己的自由、好奇、充滿創造力的想法被現實的架構所束縛,讓創造力自由成長吧! 多花時間,關心他(她)人,正如别人所關心你的。理想的騰飛與實作,沒有别人的支援與幫助,是萬萬不能的。

    本文轉自wenglabs部落格園部落格,原文連結:http://www.cnblogs.com/arxive/p/5816989.html,如需轉載請自行聯系原作者

繼續閱讀