Added waypoint detail page
This commit is contained in:
@@ -7,6 +7,8 @@ using Windows.ApplicationModel.Resources;
|
|||||||
using Windows.Devices.Geolocation;
|
using Windows.Devices.Geolocation;
|
||||||
using Windows.Services.Maps;
|
using Windows.Services.Maps;
|
||||||
using Windows.UI;
|
using Windows.UI;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Controls.Maps;
|
using Windows.UI.Xaml.Controls.Maps;
|
||||||
|
|
||||||
namespace NavCityBreda.Helpers
|
namespace NavCityBreda.Helpers
|
||||||
@@ -36,6 +38,15 @@ namespace NavCityBreda.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MainPage MainPage
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
Frame f = Window.Current.Content as Frame;
|
||||||
|
MainPage mp = f.Content as MainPage;
|
||||||
|
return mp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<MapLocation> FindLocation(string location, Geopoint reference)
|
public static async Task<MapLocation> FindLocation(string location, Geopoint reference)
|
||||||
{
|
{
|
||||||
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(location, reference);
|
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(location, reference);
|
||||||
@@ -73,6 +84,36 @@ namespace NavCityBreda.Helpers
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<String> FindAddress(Geopoint p)
|
||||||
|
{
|
||||||
|
// Reverse geocode the specified geographic location.
|
||||||
|
MapLocationFinderResult result =
|
||||||
|
await MapLocationFinder.FindLocationsAtAsync(p);
|
||||||
|
|
||||||
|
string returnstring = "";
|
||||||
|
|
||||||
|
// If the query returns results, display the name of the town
|
||||||
|
// contained in the address of the first result.
|
||||||
|
if (result.Status == MapLocationFinderStatus.Success)
|
||||||
|
{
|
||||||
|
MapAddress address = result.Locations[0].Address;
|
||||||
|
|
||||||
|
//returnstring = address.Street + " " + address.StreetNumber + ", " + address.Town;
|
||||||
|
returnstring += (address.BuildingName == "" ? "" : address.BuildingName + ", ");
|
||||||
|
returnstring += (address.Street == "" ? "" : address.Street + (address.StreetNumber == "" ? ", " : " " + address.StreetNumber + ", "));
|
||||||
|
returnstring += address.Town;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<String> FindAddress(double latitude, double longitude)
|
||||||
|
{
|
||||||
|
Geopoint p = new Geopoint(new BasicGeoposition() { Latitude = latitude, Longitude = longitude });
|
||||||
|
string address = await FindAddress(p);
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
public static MapPolyline GetRouteLine(MapRoute m, Color color, int thickness = 10, bool dashed = false)
|
public static MapPolyline GetRouteLine(MapRoute m, Color color, int thickness = 10, bool dashed = false)
|
||||||
{
|
{
|
||||||
var line = new MapPolyline
|
var line = new MapPolyline
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using NavCityBreda.Helpers;
|
using NavCityBreda.Helpers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.Devices.Geolocation;
|
using Windows.Devices.Geolocation;
|
||||||
|
using Windows.UI.Xaml.Controls.Maps;
|
||||||
|
|
||||||
namespace NavCityBreda.Model
|
namespace NavCityBreda.Model
|
||||||
{
|
{
|
||||||
@@ -35,6 +37,21 @@ namespace NavCityBreda.Model
|
|||||||
_waypoints.Add(w);
|
_waypoints.Add(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Waypoint Get(int i)
|
||||||
|
{
|
||||||
|
return _waypoints.ElementAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Waypoint Get(MapIcon m)
|
||||||
|
{
|
||||||
|
List<Waypoint> ws = _waypoints.Where(p => p.Equals(m)).ToList();
|
||||||
|
|
||||||
|
if (ws.Count < 1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return ws.First();
|
||||||
|
}
|
||||||
|
|
||||||
public void Remove(Waypoint w)
|
public void Remove(Waypoint w)
|
||||||
{
|
{
|
||||||
_waypoints.Remove(w);
|
_waypoints.Remove(w);
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using NavCityBreda.Helpers;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Windows.Devices.Geolocation;
|
using Windows.Devices.Geolocation;
|
||||||
|
using Windows.UI.Xaml.Controls.Maps;
|
||||||
|
|
||||||
namespace NavCityBreda.Model
|
namespace NavCityBreda.Model
|
||||||
{
|
{
|
||||||
@@ -11,17 +13,34 @@ namespace NavCityBreda.Model
|
|||||||
{
|
{
|
||||||
public Geopoint Location { get; protected set; }
|
public Geopoint Location { get; protected set; }
|
||||||
public string Name { get; protected set; }
|
public string Name { get; protected set; }
|
||||||
|
public int Order { get; protected set; }
|
||||||
|
|
||||||
public Waypoint(Geopoint p, string name)
|
public Waypoint(Geopoint p, string name, int num)
|
||||||
{
|
{
|
||||||
Location = p;
|
Location = p;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
Order = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Waypoint(double la, double lo, string name)
|
public Waypoint(double la, double lo, string name, int num)
|
||||||
{
|
{
|
||||||
Location = new Geopoint(new BasicGeoposition() { Altitude = 0, Latitude = la, Longitude = lo });
|
Location = new Geopoint(new BasicGeoposition() { Altitude = 0, Latitude = la, Longitude = lo });
|
||||||
Name = name;
|
Name = name;
|
||||||
|
Order = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
Waypoint r = obj as Waypoint;
|
||||||
|
MapIcon i = obj as MapIcon;
|
||||||
|
|
||||||
|
if (r != null && r.Name == this.Name && r.Location == this.Location)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (i != null && i.Title == this.Name && i.Location == this.Location)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ViewModel\MapVM.cs" />
|
<Compile Include="ViewModel\MapVM.cs" />
|
||||||
<Compile Include="ViewModel\MenuVM.cs" />
|
<Compile Include="ViewModel\MenuVM.cs" />
|
||||||
|
<Compile Include="ViewModel\RouteVM.cs" />
|
||||||
<Compile Include="Views\HelpView.xaml.cs">
|
<Compile Include="Views\HelpView.xaml.cs">
|
||||||
<DependentUpon>HelpView.xaml</DependentUpon>
|
<DependentUpon>HelpView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -134,8 +135,8 @@
|
|||||||
<Compile Include="Views\SettingsView.xaml.cs">
|
<Compile Include="Views\SettingsView.xaml.cs">
|
||||||
<DependentUpon>SettingsView.xaml</DependentUpon>
|
<DependentUpon>SettingsView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\WayPointView.xaml.cs">
|
<Compile Include="Views\LandmarkView.xaml.cs">
|
||||||
<DependentUpon>WayPointView.xaml</DependentUpon>
|
<DependentUpon>LandmarkView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -221,7 +222,7 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\WayPointView.xaml">
|
<Page Include="Views\LandmarkView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<Page
|
||||||
|
x:Class="NavCityBreda.Views.LandmarkView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:NavCityBreda.Views"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<ScrollViewer>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Image Source="{Binding Image}" Grid.Row="0" />
|
||||||
|
<StackPanel Grid.Row="1" Margin="10">
|
||||||
|
<TextBlock Text="[WaypointDescription]" x:Uid="WaypointDescription" FontWeight="Bold" Margin="0,0,0,3"/>
|
||||||
|
<TextBlock TextWrapping="WrapWholeWords" Text="{Binding Description}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="10">
|
||||||
|
<SymbolIcon Symbol="Street" Foreground="Gray"/>
|
||||||
|
<ProgressRing IsActive="True" Name="StreetLoading" Foreground="Gray" Margin="10,0,0,0"/>
|
||||||
|
<TextBlock Name="StreetAddress" Text="Searching..." Foreground="Gray" Margin="10,0,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Page>
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
using NavCityBreda.Helpers;
|
||||||
|
using NavCityBreda.Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Windows.Foundation;
|
||||||
|
using Windows.Foundation.Collections;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
using Windows.UI.Xaml.Input;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
|
||||||
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
|
namespace NavCityBreda.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||||
|
/// </summary>
|
||||||
|
public sealed partial class LandmarkView : Page
|
||||||
|
{
|
||||||
|
Landmark landmark;
|
||||||
|
|
||||||
|
public LandmarkView()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
landmark = e.Parameter as Landmark;
|
||||||
|
this.DataContext = landmark;
|
||||||
|
Util.MainPage.Title = landmark.Name;
|
||||||
|
LoadStreet();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void LoadStreet()
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromMilliseconds(350));
|
||||||
|
string address = await Util.FindAddress(landmark.Location);
|
||||||
|
StreetLoading.IsActive = false;
|
||||||
|
StreetLoading.Visibility = Visibility.Collapsed;
|
||||||
|
StreetAddress.Text = address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,8 @@ using Windows.UI.Xaml.Controls.Maps;
|
|||||||
using NavCityBreda.Model;
|
using NavCityBreda.Model;
|
||||||
using Windows.Storage.Streams;
|
using Windows.Storage.Streams;
|
||||||
using Windows.UI.Popups;
|
using Windows.UI.Popups;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using NavCityBreda.Helpers;
|
||||||
|
|
||||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
@@ -46,18 +48,19 @@ namespace NavCityBreda.Views
|
|||||||
|
|
||||||
private void DrawLandmarks()
|
private void DrawLandmarks()
|
||||||
{
|
{
|
||||||
foreach(Route r in App.RouteManager.Routes)
|
Route r = App.RouteManager.CurrentRoute;
|
||||||
|
|
||||||
|
Map.MapElements.Clear();
|
||||||
|
|
||||||
|
foreach(Landmark l in r.Waypoints.Where(l => l is Landmark))
|
||||||
{
|
{
|
||||||
foreach(Landmark l in r.Waypoints.Where(l => l is Landmark))
|
MapIcon m = new MapIcon();
|
||||||
{
|
m.Location = l.Location;
|
||||||
MapIcon m = new MapIcon();
|
m.NormalizedAnchorPoint = new Point(0.5, 1.0);
|
||||||
m.Location = l.Location;
|
m.Title = l.Name;
|
||||||
m.NormalizedAnchorPoint = new Point(0.5, 1.0);
|
m.ZIndex = 10;
|
||||||
m.Title = l.Name;
|
//m.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///" + l.Image));
|
||||||
m.ZIndex = 10;
|
Map.MapElements.Add(m);
|
||||||
//m.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///" + l.Image));
|
|
||||||
Map.MapElements.Add(m);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,10 +82,17 @@ namespace NavCityBreda.Views
|
|||||||
|
|
||||||
private void Map_MapElementClick(MapControl sender, MapElementClickEventArgs args)
|
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");
|
MapIcon i = args.MapElements.Where(p => p is MapIcon).Cast<MapIcon>().First();
|
||||||
m.ShowAsync();
|
|
||||||
|
|
||||||
Map.TrySetViewBoundsAsync(App.RouteManager.Routes.First().Bounds, new Thickness(10), MapAnimationKind.Bow);
|
Waypoint w = App.RouteManager.CurrentRoute.Get(i);
|
||||||
|
if (!(w is Landmark))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Landmark l = w as Landmark;
|
||||||
|
|
||||||
|
Util.MainPage.Navigate(typeof(LandmarkView), l);
|
||||||
|
|
||||||
|
//Map.TrySetViewBoundsAsync(App.RouteManager.Routes.First().Bounds, new Thickness(10), MapAnimationKind.Bow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<Page
|
|
||||||
x:Class="NavCityBreda.Views.WayPointView"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:local="using:NavCityBreda.Views"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
mc:Ignorable="d">
|
|
||||||
|
|
||||||
<Grid>
|
|
||||||
<TextBlock Text="Waypoint"/>
|
|
||||||
</Grid>
|
|
||||||
</Page>
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
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;
|
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
|
||||||
using Windows.UI.Xaml.Data;
|
|
||||||
using Windows.UI.Xaml.Input;
|
|
||||||
using Windows.UI.Xaml.Media;
|
|
||||||
using Windows.UI.Xaml.Navigation;
|
|
||||||
|
|
||||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
|
||||||
|
|
||||||
namespace NavCityBreda.Views
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
||||||
/// </summary>
|
|
||||||
public sealed partial class WayPointView : Page
|
|
||||||
{
|
|
||||||
public WayPointView()
|
|
||||||
{
|
|
||||||
this.InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user