用DrawObject画框,并选中框框内的图元:
//fLayer为FeatureLayer
double x1, y1, x2, y2;
mapControl.MapToScreen(rc.XMin, rc.YMin, out x1, out y1);
mapControl.MapToScreen(rc.XMax, rc.YMax, out x2, out y2);
//需要将屏幕坐标点转到Application.Current.RootVisual对应的坐标点
var trans = mapControl.TransformToVisual(Application.Current.RootVisual);
//注意:pt1为最小坐标,pt2为最大坐标
var pt1 = trans.Transform(new Point(Math.Min(x1, x2), Math.Min(y1, y2)));
var pt2 = trans.Transform(new Point(Math.Max(x1, x2), Math.Max(y1, y2)));
var ftrs = fLayer.FindGraphicsInHostCoordinates(new Rect(pt1, pt2));
foreach (var ftr in ftrs)
ftr.Select();

本文介绍如何利用DrawObject工具在地图上绘制矩形选择框,并通过转换坐标系找到被选框覆盖的所有图元。文章详细展示了如何计算并转换坐标,以及如何使用FeatureLayer的FindGraphicsInHostCoordinates方法来获取选定区域内的所有图元。

被折叠的 条评论
为什么被折叠?



