1

My app is moving a vehicle on specified route using below code. But the image of vehicle used is like it's front side is facing to left. How can I rotate the face of car on the way it goes? I'm referring this link to move the car.

My Code :

  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();
     }
user2431727
  • 877
  • 2
  • 15
  • 46
  • You could use https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.rotatetransform to rotate your image – TheTanic Jul 25 '18 at 13:02

1 Answers1

0

If you just put a general Image control on the MapControl, the rotation transform will not work. Justin XL has explained on this thread: How to rotate image placed on a Mapcontrol.

The solution is like the Justin XL said:

create a UserControl called ImageControl which encapsulates this Image and its transform, with dependency properties like UriPath and Angle that are responsible for passing the information down to the inner Image and its CompositeTransform property.

Xie Steven
  • 8,544
  • 1
  • 9
  • 23