变换路径/折线对应于地图缩放/移动动作

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

现在,我希望路径在用户操纵地图的同时进行变换(缩放和地图重新定位),因此路径仍然连接相同的点。 到目前为止,我的方法非常耗费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方法? 我找到了关于如何缩放地图的旧线程 ,但在我的情况下,地图存储的缩放级别只是1到20之间的数值,没有每个缩放跳跃的比例%的指示。

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