MapPolyline not drawn

I am trying to use MapPolyLine on my map to show the route in real time, I hope that it will move / scale this time . The fact is that the line is not displayed on the map, and I can not find the programming error:

FROM#

MapLayer pathLayer; //Constructor pathLayer = new MapLayer(); MapPolyline line = new MapPolyline(); line.StrokeColor = Colors.Red; line.StrokeThickness = 10; //line.Path.Add(several points); Tested, no effect MapOverlay overlay = new MapOverlay(); overlay.Content = line; //overlay.GeoCoordinate = new GeoCoordinate(0,0); Tested, no effect //overlay.PositionOrigin = new Point(0.0, 1.0); Tested, no effect pathLayer.Add(overlay); MyMap.Layers.Add(pathLayer); void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { MapPolyline line = pathLayer.First(TrackPath).Content as MapPolyline; line.Path.Add(args.Position.Coordinate); // Checked values, line.Path adds them correctly } 

EDIT: New Information. The emulator shows an error when trying to add it using XAML, and the emulator shows the class name at the top of the map as a graphical failure:

Emulator error on top, XAML on the right

+3
source share
2 answers

MapPolylines and MapPolygons should be added to the MapElements collection ... not a MapLayer or MapOverlay .

You should be able to do this work example for you.

  MapPolyline line = new MapPolyline(); line.StrokeColor = Colors.Red; line.StrokeThickness = 10; line.Path.Add(new GeoCoordinate(47.6602, -122.098358)); line.Path.Add(new GeoCoordinate(47.561482, -122.071544)); MyMap.MapElements.Add(line); 

In your GeoCoord observer, you will need to get a line from the MapElements collection and add a new position to the line path instead of predefined, like me. It should be doable.

+9
source

In Windows Phone 8.1, try adding dots this way. "punkty" is my collection.

  List<BasicGeoposition> PosList = new List<BasicGeoposition>(); foreach (var item in punkty) { PosList.Add(new BasicGeoposition() { Latitude = item.Position.Latitude, Longitude = item.Position.Longitude }); } //Example of one point //PosList.Add(new BasicGeoposition() //{ // Latitude = 52.46479093, // Longitude = 16.91743341 //}); MapPolyline line = new MapPolyline(); line.StrokeColor = Colors.Red; line.StrokeThickness = 5; line.Path = new Geopath(PosList); myMap.MapElements.Add(line); 
0
source

All Articles