【问题标题】:UWP mapcontrol mapicon rotate with map, need to be fixedUWP mapcontrol mapicon 随地图旋转,需要固定
【发布时间】:2016-10-04 16:53:28
【问题描述】:

UWP mapcontrol mapicon 随地图旋转,需要修复。不知道如何修复它或任何解决方法。 unrotated maprotated map

用下面的代码添加图标

    private async void Add_cam(Geocoordinate Coordinate,GPoint point,string text,WriteableBitmap wb)
    {
        MapIcon icon = new MapIcon();
        InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
        await wb.RotateFree(point.angle).ToStream(ras, BitmapEncoder.PngEncoderId);
        var str = RandomAccessStreamReference.CreateFromStream(ras);

        icon.Image = str;
        icon.NormalizedAnchorPoint = new Point(0.5, 0.5);

        icon.Location = new Geopoint(new BasicGeoposition()
        {
            Altitude = Coordinate.Point.Position.Altitude,
            Longitude = point.x,
            Latitude = point.y
        });
        icon.Title = text;
        Map.MapElements.Add(icon);
    }

【问题讨论】:

  • 在您的捕获按钮上创建一个RotateTransform 并将角度设置为实际地图旋转的负角。这样您的图标将始终保持正确的角度。

标签: c# uwp


【解决方案1】:

没有旋转MapIcon的方法,因为它继承自MapElement,而不是UIElement,它没有实现Transform函数。

所以解决这种情况的一个简单方法是用Image控件替换这个MapIcon并旋转这个Image,要做到这一点,你可以参考这个案例:UWP MapControl: MapElement fixed heading

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    相关资源
    最近更新 更多