From 324ccb2985bd501c6077b227695c54c9eed0f4d0 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Thu, 17 Dec 2015 00:21:56 +0100 Subject: [PATCH] Show all landmarks on map --- NavCityBreda/Views/MapView.xaml.cs | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/NavCityBreda/Views/MapView.xaml.cs b/NavCityBreda/Views/MapView.xaml.cs index 4c72d21..c04485f 100644 --- a/NavCityBreda/Views/MapView.xaml.cs +++ b/NavCityBreda/Views/MapView.xaml.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; @@ -15,6 +14,9 @@ using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; using Windows.Devices.Geolocation; using Windows.UI.Xaml.Controls.Maps; +using NavCityBreda.Model; +using Windows.Storage.Streams; +using Windows.UI.Popups; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 @@ -35,8 +37,28 @@ namespace NavCityBreda.Views this.DataContext = new MapVM(); CurrenPosition = new MapIcon(); + Map.MapElements.Add(CurrenPosition); App.Geo.PositionChanged += Geo_PositionChanged; + + DrawLandmarks(); + } + + private void DrawLandmarks() + { + foreach(Route r in App.RouteManager.Routes) + { + foreach(Landmark l in r.Waypoints.Where(l => l is Landmark)) + { + MapIcon m = new MapIcon(); + m.Location = l.Location; + m.NormalizedAnchorPoint = new Point(0.5, 1.0); + m.Title = l.Name; + m.ZIndex = 10; + //m.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///" + l.Image)); + Map.MapElements.Add(m); + } + } } private void Geo_PositionChanged(Geolocator sender, PositionChangedEventArgs args) @@ -53,8 +75,14 @@ namespace NavCityBreda.Views CurrenPosition.NormalizedAnchorPoint = new Point(0.5, 1.0); CurrenPosition.Title = "Current Position"; CurrenPosition.ZIndex = 999; + } - Map.MapElements.Add(CurrenPosition); + private void Map_MapElementClick(MapControl sender, MapElementClickEventArgs args) + { + MessageDialog m = new MessageDialog("Not yet implemnted. Not sure how to get the tapped element.", "Element tapped"); + m.ShowAsync(); + + Map.TrySetViewBoundsAsync(App.RouteManager.Routes.First().Bounds, new Thickness(10), MapAnimationKind.Bow); } } }