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.
http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/xamGeographicMap_Using_Geographic_Polyline_Series.html
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 { get; set; } //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"> </ig:GeographicPolylineSeries>
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) } } }; _arrows.Add(arrow);
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:
http://ko.infragistics.com/products/silverlight/application-samples
and another random suggestion. Infragistics search is Terrible. Awefull.Instead use Google Search for their site like this: https://www.google.com/search?q=site%3Awww.infragistics.com+flight%2Bwatcher
Hi Will,
Thank you for posting this! This should prove useful to our customers for data binding to a polyline series.