:::: MENU ::::

Drawing line on Map control in Windows Phone 8.1 using MapPolyline

In windows phone there is separate API for showing route between two coordinates. MapLocationFinder is used for showing walking and driving direction. But sometime scenario will be different in my case, I have to plot air route that plane travel from Location A to Location B. For this case i used MapPolyline class to draw line between coordinates on map.

In my case I have list of coordinates that plane travel between Location A to Location B and I plot them in map. Here is how I do this.

Here I make a collection of positions. Datas is the list having coordinates and other details so i am filtering coordinates in separate list called PosList using foreach loop and pass PosList to the Path property of MapPolyline class object line by warping it in Geopath object which represents the ordered series of geographic points. And at last adding the line object on the map using MapFlight.MapElements.Add() method. Here MapFlight is the name of Map control. You can set other properties of MapPloyline object like StrokeColor, StrokeThickness etc. etc.

This is how you can draw line between coordinates on map in Windows phone 8.1. Here is image after plotting.

P.S When i used this class it is in preview phase.

Happy coding!!! 🙂