arcgis engine 当在文本框输入一个城市,在地图上查找,当找到后怎么让mapcontrol自动跳转到地图上该点?

2025-04-07 00:36:48
推荐回答(1个)
回答1:

  参照下面代码,希望对你有帮助
   IQueryFilter filter = new QueryFilterClass();
                filter.WhereClause = " NAME='"+城市名称+"'";
   IFeatrueSel.SelectFeatures(filter, esriSelectionResultEnum.esriSelectionResultNew, false);
                    IFeatureCursor cursor = IFeatureLay.Search(filter, false);
                    IFeature feat = cursor.NextFeature();
                    if (feat != null)
                    {
                        //先清除地图中被选中的要素
                        this.axMapControl1.Map.ClearSelection();
                        IGeometry zdGeo = feat.Shape;
                        try
                        {
                            this.axMapControl1.ActiveView.ExtentStack.Do(zdGeo.Envelope);
                            this.axMapControl1.ActiveView.Extent = zdGeo.Envelope;
                            this.axMapControl1.ActiveView.Refresh();
                            this.axMapControl1.FlashShape(zdGeo, 2, 300, Type.Missing);
                        }
                        catch (Exception ex)
                        {                           
                            return;
                        }
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);