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

标签 c# wcf xaml windows-phone-8 here-api

我正在使用 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/

相关文章:

c# - 类型 'string' 必须是不可为 null 的值类型才能将其用作泛型类型或方法 'T' 中的参数 'System.Nullable<T>'

wcf - 契约(Contract)需要 Session,但 Binding 'BasicHttpBinding' 不支持它或未正确配置以支持它

c# - WCF 服务依赖项

c# - 如何将 Xml 属性绑定(bind)到 Treeview 节点,同时将 XDocument 数据绑定(bind)到 WPF Treeview

wpf - 跳转到 UserControl 内的导航

c# - C#中所有的数组都实现了哪些接口(interface)?

c# - 系统.IO.IOException : Cannot close stream until all bytes are written

wcf - Remoting 和 Wcf 之间的 Http 请求数差异

wpf - 有没有办法在 XAML 中链接多个值转换器?

c# - 如何使关闭按钮像最小化一样工作 : C# Winforms