`
mmdev
  • 浏览: 12949108 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

MapXtreme2004代码 搜索指定点的最近图元(SearchNearst)

 
阅读更多

// 这里默认搜索离地图中心点最近的图元

DPoint ppt=MapControl1.Map.Center;

Map map = MapControl1.Map;

ISession session = MapInfo.Engine.Session.Current;

// 半径设置为5象素

Distance d =MapInfo.Mapping.SearchInfoFactory.ScreenToMapDistance(map, 5);

SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchNearest(ppt,map.GetDisplayCoordSys(),d);

// 搜索所有列

si.QueryDefinition.Columns = null;

// 搜到一个就停止搜索

(si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;

// 搜索到的图元放入DefaultSelection

session.Catalog.Search("asicty79",si,session.Selections.DefaultSelection, ResultSetCombineMode.Replace);

// 得到FeatureCollection

MapInfo.Data.Table table = session.Catalog["asicty79"];

IResultSetFeatureCollection fc = session.Selections.DefaultSelection[table];

if (fc.Count==0)

Response.Write("没有搜索到任何图元!");

// 需要注意的是该图层必须设置为可以选择的 这样在地图上才能看出效果

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics