Skip to content

Plotting routes onto Bing Maps in WP7 and storing it an Obversable Collection

June 25, 2011

So you wanted to know how to plot routes onto Bing Maps using MapPolyLine that sets from one geocordinate to another, and store all these in an Obeservable Collection. Here's the code that does the basis of these: -

MapPolyline polyline = new MapPolyline(); 
polyline.Stroke = stroke; 
polyline.StrokeThickness = strokeThinkness; 
polyline.Opacity = opacity; 
polyline.Locations = locationsList; 
map.Children.Add(polyline); (where map is the XAML object that is the Bing Map)

var locationsList = new LocationCollection(); 
locationsList.Add(new GeoCoordinate(latitude1, longtitude1, altitude1)); 
locationsList.Add(new GeoCoordinate(latitude2, longtitude2, altitude2)); 
locationsList.Add(new GeoCoordinate(latitude3, longtitude3, altitude3)); 

(where altitude1, altitude2, and altitude3 can be null)

The LocationCollection is just basically an ObservableCollection of GeoCoordinates, and you don’t have to include altitude variable but you must include the longitude and latitude.

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: