0

I'm using MapControl to draw route on map (using GMapsUWPSDK). It draws the routes using set of locations. Now I want to move a vehicle on this route. For that I have done like below.

Image vehicleImg = new Image
{
Width = 40,
Source = VehicleIconSource    
}; 
MyMap.Children.Add(vehicleImg);

AddLocationsOfVehicle() //location of vehicle change when calling this function
{
BasicGeoposition geoposition = new BasicGeoposition();
geoposition.Latitude = AppGlobals._VehicleDetailsList[0].VLat;
geoposition.Longitude = AppGlobals._VehicleDetailsList[0].VLng;
Geopoint mypoint = new Geopoint(geoposition);
MapControl.SetLocation(vehicleImg , mypoint);
}

Now the vehicle is jumping from one location to another.Instead of it, How can I move the vehicle from one point to another? Is this the correct way to add a vehicle on route? Is there any useful link to achieve this task? Also,now the vehicle is not correctly placing on the route as in google map. Image is seen as just outside the route. How can I rotate/turn the vehicle, When reaching turns ?

nsds
  • 961
  • 4
  • 13
  • 39

1 Answers1

1

You can add pushpin(Marker) for that, and supply your custom car image in the Image property See this

Here is the sample code

public void AddSpaceNeedleIcon()
{
    var MyLandmarks = new List<MapElement>();

    BasicGeoposition snPosition = new BasicGeoposition { Latitude = 47.620, Longitude = -122.349 };
    Geopoint snPoint = new Geopoint(snPosition);

    var spaceNeedleIcon = new MapIcon
    {
        Location = snPoint,
        NormalizedAnchorPoint = new Point(0.5, 1.0),
        ZIndex = 0,
        Title = "Space Needle"
    };

    MyLandmarks.Add(spaceNeedleIcon);

    var LandmarksLayer = new MapElementsLayer
    {
        ZIndex = 1,
        MapElements = MyLandmarks
    };

    myMap.Layers.Add(LandmarksLayer);

    myMap.Center = snPoint;
    myMap.ZoomLevel = 14;

}
Mihir Dave
  • 3,954
  • 1
  • 12
  • 28
  • How can animate that image? I want to move it through specified routes – nsds Jul 19 '18 at 10:52
  • at certain interval keep changing BasicGeoposition property of marker on your route in incremental order. that'll give you animation effect – Mihir Dave Jul 19 '18 at 10:55
  • It shows : Requested Windows Runtime type 'Windows.UI.Xaml.Controls.Maps.MapElementsLayer' is not registered – nsds Jul 20 '18 at 03:51
  • MapElementsLayer is not supported for lower version of devices – nsds Jul 24 '18 at 07:33