根据路径旋转MapControl上的销钉-Uwp C#

时间:2018-07-25 12:00:37

标签: c# google-maps uwp

我的应用使用以下代码在指定路线上行驶车辆。但是所用车辆的图像就像它的正面朝左。如何在行驶过程中旋转汽车的外观?我指的是这个link来开车。

我的代码:

  private void MovePinOnPath(bool isGeodesic)
    {      
    Image forImage = new Image
    {
        Width = 40,
        Source = CarIconSource,
    };
            BasicGeoposition geoposition = new BasicGeoposition();
            geoposition.Latitude = CarDetailsList.CodeArray[Startpt_index].CarLat;
            geoposition.Longitude = CarDetailsList.CodeArray[Startpt_index].CarLng;
            Geopoint mypoint2 = new Geopoint(geoposition);
            List<BasicGeoposition> GeoList = new List<BasicGeoposition>();
            for (int i = Startpt_index + 1; i <= Endpt_index; i++)
            {
                GeoList.Add(new BasicGeoposition()
                {
                    Latitude =  CarDetailsList.CodeArray[i].CarLat;
                    Longitude = CarDetailsList.CodeArray[i].CarLng;
                });
            }
            Geopath path3 = new Geopath(GeoList);
            MapControl.SetLocation(forImage, mypoint2);
            MapControl.SetNormalizedAnchorPoint(forImage, new Point(0.5, 1.0));
            currentAnimation = new PathAnimation(path3, (coord, pathIdx, frameIdx) =>
            {
                MapControl.SetLocation(forImage, new Geopoint(coord));
            }, isGeodesic, 10000);

            currentAnimation.Play();
     }

1 个答案:

答案 0 :(得分:0)

如果仅将常规Image控件放在MapControl上,则旋转变换将不起作用。贾斯汀XL在此线程上进行了解释:How to rotate image placed on a Mapcontrol

解决方案就像贾斯汀XL所说:

  

创建一个名为ImageControl的UserControl,该UserControl封装此Image及其转换,并具有UriPath和Angle等依赖项属性,这些依赖项属性负责将信息向下传递到内部Image及其CompositeTransform属性。