MapXtreme 查找图元

private void FindYuansu(string _findLayerName, string _findColumnName,string _findname)
    {
        Find find = null;
        try
        {
            MapInfo.Mapping.Map map = null;
            //获取地图
            if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 ||
                 (map = MapInfo.Engine.Session.Current.MapFactory[0]) == null)
            {
                return;
            }
            //开始搜索
            MapInfo.Mapping.FeatureLayer findLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[_findLayerName];
            find = new Find(findLayer.Table, findLayer.Table.TableInfo.Columns[_findColumnName]);
            FindResult result = find.Search(_findname);
            if (result.ExactMatch)
            {
                //重新设置地图
                map.Center = new DPoint(result.FoundPoint.X, result.FoundPoint.Y);
                MapInfo.Geometry.Distance d = new MapInfo.Geometry.Distance(0.8, map.Zoom.Unit);
                map.Zoom = d;
            }
            else
            {
                Response.Write("没有搜索到!");
            }
            find.Dispose();
        }
        catch (Exception)
        {
            if (find != null) find.Dispose();
        }
    }

posted on 2013-02-25 10:29  读懂洋字码  阅读(229)  评论(0编辑  收藏  举报