This question is locked. New answers and comments are not allowed.
I'm using MVVM in my project and have a datagrid with multiple Locatios (Lat/Lon) and also has trips with multiple points (various Lat/Lon points for a MapPolyline). All with "MapIt" buttons for when the user wants to either see where something happened or what route they took on the map.
I'm trying to figure out how I can bind my informationLayer to my VM to either display a MapPinPoint or a MapPolyline but am failing miserable. :(
Here is what I have so far:
Map Control:
VM:
Thanks in advance!
I'm trying to figure out how I can bind my informationLayer to my VM to either display a MapPinPoint or a MapPolyline but am failing miserable. :(
Here is what I have so far:
Map Control:
<telerik:RadMap x:Name="HistoryMapping"> <telerik:RadMap.Provider> <telerik:BingMapProvider ApplicationId="TakenOutForSecurityPurposes" /> </telerik:RadMap.Provider> <telerik:InformationLayer x:Name="historyInformationLayer" ItemsSource="{Binding MapSource}"> </telerik:InformationLayer> </telerik:RadMap>VM:
private ObservableCollection<object> mapSource; public ObservableCollection<object> MapSource { get { return mapSource; } set { mapSource = value; RaisePropertyChanged("MapSource"); } }MapItDataGridCommand = new RelayCommand<object>((e) => { IsAppBusy = true; StoryboardManager.PlayStoryboard("CloseHistoryGridAnimation", (o) =>}, null); try { BingRouteProvider routeProvider = new BingRouteProvider(); routeProvider.ApplicationId = "TakenOutForSecurityPurposes"; routeProvider.MapControl = new RadMap();
routeProvider.RoutingCompleted += new EventHandler<RoutingCompletedEventArgs>(routeProvider_RoutingCompleted); TripSummary trp = (TripSummary)e; RouteRequest request = new RouteRequest(); Location loc1 = new Location(trp.TripStart.Lat, trp.TripStart.Lon); Location loc2 = new Location(trp.TripEnd.Lat, trp.TripEnd.Lon); request.Waypoints.Add(loc1); request.Waypoints.Add(loc2); routeProvider.CalculateRouteAsync(request); } catch (Exception) { //LocationPoint locPt = (LocationPoint) e; //MapPinPoint pnpoint = new MapPinPoint(); //Location loc = new Location(locPt.Lat,locPt.Lon); } }); } void routeProvider_RoutingCompleted(object sender, RoutingCompletedEventArgs e) { RouteResponse response = e.Response as RouteResponse; if (response != null) { if (response.Result == null) return; if (response.Result.RoutePath != null) { MapPolyline route = new MapPolyline(); route.Points = response.Result.RoutePath.Points; route.Stroke = new SolidColorBrush(Colors.Red); route.StrokeThickness = 3; mapSource = new ObservableCollection<object>(); MapSource.Add(route);
IsAppBusy = false;
} } }Thanks in advance!