gpt4 book ai didi

c# - 对应 map 缩放/移动 Action 的Transform Path/Polyline

转载 作者:行者123 更新时间:2023-11-30 18:36:34 29 4
gpt4 key购买 nike

我正在使用 MapLayer 和 MapOverlay 在 map 中创建自己的路径/折线,GPS 捕获的所有点都存储在一个结构中,以便我可以访问它们。随时。

现在,我希望路径在用户操作 map (缩放和 map 重新定位)的同时进行变换,因此路径仍然连接相同的点。到目前为止,我的方法非常耗费 CPU,看起来很糟糕

GeocoordinateList _coordinates;
MapLayer pointsLayer;

private void MyMap_ZoomLevelChanged(object sender, MapZoomLevelChangedEventArgs e)
{
repositionPoints(); // This is done other way but for the sake of brevity
}

private void repositionPathPoints()
{
try
{
Polyline path = (Polyline)pointsLayer.First(TrackPath).Content; // retrieves MapOverlay corresponding to line
path.Points.Clear();
path.Points = new PointCollection();
foreach (Geocoordinate coord in _coordinates)
{
path.Points.Add(MyMap.ConvertGeoCoordinateToViewportPoint(coord));
}

}
catch (Exception exc)
{
Debug.WriteLine(exc.Message);
}
}

是否有使用 XAML 方法更有效地执行此操作的方法?我找到了 this old thread关于如何缩放 map ,但在我的例子中, map 存储的缩放级别只是一个从 1 到 20 的数值,没有指示每次缩放跳跃的比例百分比。

最佳答案

我通过阅读文档解决了这个问题。我真正需要的是 SDK 已经提供的 MapPolyline,其方法接受地理坐标而不是点。您只需将它们添加为 MapElements 或 MapLayer 的子元素。

关于c# - 对应 map 缩放/移动 Action 的Transform Path/Polyline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13607184/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com