Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Bind XamGeographicMap to Custom MarkerSymbols and Custom PolyLines

This is just a helpful post for anyone out there trying to use the Geographic MAp do the same thing that I was.

It was not immediately understandable through the Silverlight demos, if this was possible or not.

I wanted to bind a bunch of custom data in C# classes directly to the Polylines collection in the map.  So I started by checking out the PolyLine Example.

The link for Polylines on XamGeographicMap says that it is possible to Bind Custom objects and have them display on the map as polylines.

This link is for WPF, but the same thing is also possible in Silverlight.

"Similarly to other types of geographic series in the xamGeographicMap control, the GeographicPolylineSeries has the ItemsSource property for the purpose of data binding. This property can be bound to an object that implements the IEnumerable interface  (e.g. List, Collection, Queue, Stack). In addition, each item in this object must have one data column that stores geographic locations (longitude and latitude) of connected items using the IEnumerable<Point> or IEnumerable<IEnumerable<Point>> structure."


So I figured out that the following class will bind correctly to the Polylines.

    	public class Arrow
 public IEnumerable<IEnumerable<Point>> Points { getset; }  //Please NOTE: {get; set;} here is VERY important for data binding.
		//Other members here.
then I have inside my map on the xaml side
 <ig:GeographicPolylineSeries ItemsSource="{Binding}" ShapeMemberPath="Points" Name="LineSeries" Thickness="2">
And then I instantiate a bunch of arrows (could be any object/class) in a list called _arrows
	_arrows = new ObservableCollection<Arrow>();
 var arrow = new Arrow
                            Points = new List<List<Point>>
                                    new List<Point>{
                                        new Point(flight.OriginLongitude, flight.OriginLatitude),
                                        new Point((flight.OriginLongitude + flight.DestinationLongitude)/2, 
                                            (flight.OriginLatitude+ flight.DestinationLatitude)/2),
                                        new Point(flight.DestinationLongitude, flight.DestinationLatitude)
and Finally, I bind the collection of arrows to the data series.
	GeoMap.Series["LineSeries"].DataContext = _arrows;


For anyone that needs to also see the custom Marker\Symbol series, a great demo of theirs is the "Flight Watcher" 
which uses NON shapefiles (XML) to read a bunch of data and then has moving planes on the map. You can find Flight Watcher on the list here:
and another random suggestion.  Infragistics search is Terrible.  Awefull.
Instead use Google Search for their site like this: