Finished navigation and camera controls
This commit is contained in:
@@ -243,4 +243,7 @@
|
||||
<data name="RouteIn" xml:space="preserve">
|
||||
<value>in</value>
|
||||
</data>
|
||||
<data name="LandmarkReached" xml:space="preserve">
|
||||
<value>You have reached a landmark</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -243,4 +243,7 @@
|
||||
<data name="RouteIn" xml:space="preserve">
|
||||
<value>over</value>
|
||||
</data>
|
||||
<data name="LandmarkReached" xml:space="preserve">
|
||||
<value>U heeft een bezienswaardigheid bereikt</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -63,8 +63,7 @@
|
||||
<SplitView.Pane>
|
||||
<RelativePanel Name="MySplitviewPane" VerticalAlignment="Stretch"
|
||||
ManipulationMode="TranslateX"
|
||||
ManipulationCompleted="MySplitviewPane_ManipulationCompleted"
|
||||
Background="Transparent">
|
||||
ManipulationCompleted="MySplitviewPane_ManipulationCompleted" Style="{ThemeResource DarkModeFix}">
|
||||
|
||||
<ListBox RelativePanel.AlignTopWithPanel="True" SelectionMode="Single" Name="NavList" SelectionChanged="NavList_SelectionChanged" Tapped="NavList_Tapped">
|
||||
<ListBoxItem Name="NavListMap">
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace NavCityBreda.Model
|
||||
});
|
||||
_currentlandmark = i;
|
||||
LandmarkVisited(i, LandmarkVisitedEventArgs.VisitedStatus.ENTERED);
|
||||
Util.SendToastNotification(i.Name, "TRANSLATED MESSAGE");
|
||||
Util.SendToastNotification(i.Name, Util.Loader.GetString("LandmarkReached"));
|
||||
UpdateRoute();
|
||||
}
|
||||
|
||||
@@ -197,8 +197,6 @@ namespace NavCityBreda.Model
|
||||
|
||||
public async void StartRoute(Route r)
|
||||
{
|
||||
Util.SendToastNotification("Starting", "TRANSLATED MESSAGE");
|
||||
|
||||
App.Geo.ClearHistory();
|
||||
_currentroute = r;
|
||||
await UpdateRoute();
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:NavCityBreda.Themes">
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Style TargetType="RelativePanel" x:Key="DarkModeFix">
|
||||
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -2,5 +2,9 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:NavCityBreda.Themes">
|
||||
|
||||
|
||||
<Style TargetType="RelativePanel" x:Key="DarkModeFix">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -73,6 +73,19 @@ namespace NavCityBreda.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool Tracking
|
||||
{
|
||||
get
|
||||
{
|
||||
return Settings.Tracking;
|
||||
}
|
||||
set
|
||||
{
|
||||
Settings.Tracking = value;
|
||||
NotifyPropertyChanged(nameof(Tracking));
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateMap()
|
||||
{
|
||||
if(App.MainPage != null)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<Page.Resources>
|
||||
<convert:BoolToVisibilityConverter x:Key="BoolConverter" />
|
||||
</Page.Resources>
|
||||
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
@@ -21,18 +21,32 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Background="Gray" Visibility="{Binding Instructions, Converter={StaticResource BoolConverter}}">
|
||||
<Viewbox StretchDirection="DownOnly" Stretch="UniformToFill" Margin="10,5,10,5">
|
||||
<TextBlock FontSize="20" Text="{Binding Landmark}" Foreground="White" />
|
||||
<Viewbox Grid.Column="1" StretchDirection="DownOnly" Stretch="UniformToFill" Margin="10,5,10,5">
|
||||
<TextBlock FontSize="20" Text="{Binding Landmark}" Foreground="White" Tapped="LandmarkName_Tapped" />
|
||||
</Viewbox>
|
||||
</StackPanel>
|
||||
|
||||
<map:MapControl Grid.Row="1" Name="Map" MapElementClick="Map_MapElementClick" ZoomInteractionMode="GestureAndControl" PedestrianFeaturesVisible="True" PanInteractionMode="Auto" TiltInteractionMode="ControlOnly" RotateInteractionMode="GestureAndControl" MapServiceToken="74Y70e71HVjjN7lnx4Eh~3wugTlBDe2DbPGuR_AM2aA~AjMbg-pU2qn4gYf97oH0GZI1oY9Jc4vH-4WyIRyoYQM0Q71CnfbWalEN37bdSgms" />
|
||||
|
||||
<StackPanel Grid.Row="2" Background="LightGray" Visibility="{Binding Instructions, Converter={StaticResource BoolConverter}}">
|
||||
<Viewbox StretchDirection="DownOnly" Stretch="UniformToFill" Margin="10,5,10,5">
|
||||
<map:MapControl Grid.Row="1" Name="Map" MapElementClick="Map_MapElementClick" PedestrianFeaturesVisible="True" MapServiceToken="74Y70e71HVjjN7lnx4Eh~3wugTlBDe2DbPGuR_AM2aA~AjMbg-pU2qn4gYf97oH0GZI1oY9Jc4vH-4WyIRyoYQM0Q71CnfbWalEN37bdSgms" />
|
||||
|
||||
<Grid Grid.Row="2" Background="LightGray" Visibility="{Binding Instructions, Converter={StaticResource BoolConverter}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Grid.Column="0" Click="RecalculateRoute_Click" VerticalAlignment="Stretch">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" />
|
||||
</Button>
|
||||
|
||||
<Viewbox Grid.Column="1" StretchDirection="DownOnly" Stretch="UniformToFill" Margin="10,5,10,5">
|
||||
<TextBlock FontSize="14" Text="{Binding Maneuver}" />
|
||||
</Viewbox>
|
||||
</StackPanel>
|
||||
|
||||
<ToggleButton Grid.Column="2" Name="TrackUser" Click="TrackUser_Click" IsChecked="{Binding Tracking}" VerticalAlignment="Stretch">
|
||||
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" />
|
||||
</ToggleButton>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
</Page>
|
||||
@@ -37,6 +37,8 @@ namespace NavCityBreda.Views
|
||||
MapIcon CurrentPosition;
|
||||
MapPolyline CurrentNavigationLine;
|
||||
|
||||
private bool Zooming = false;
|
||||
|
||||
MapVM mapvm;
|
||||
|
||||
public MapView()
|
||||
@@ -52,10 +54,8 @@ namespace NavCityBreda.Views
|
||||
CurrentPosition.Title = "";
|
||||
CurrentPosition.ZIndex = 999;
|
||||
CurrentPosition.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/CurrentLocationRound.png"));
|
||||
Map.MapElements.Add(CurrentPosition);
|
||||
|
||||
CurrentNavigationLine = new MapPolyline() { StrokeColor = Color.FromArgb(255, 255, 100, 100), StrokeThickness = 6, ZIndex = 100 };
|
||||
//Map.MapElements.Add(CurrentNavigationLine);
|
||||
CurrentNavigationLine = new MapPolyline() { StrokeColor = Color.FromArgb(255, 125, 255, 150), StrokeThickness = 5, ZIndex = 100 };
|
||||
|
||||
App.Geo.OnPositionUpdate += Geo_OnPositionUpdate;
|
||||
App.RouteManager.OnStatusUpdate += RouteManager_OnStatusUpdate;
|
||||
@@ -63,6 +63,8 @@ namespace NavCityBreda.Views
|
||||
App.RouteManager.OnLandmarkVisited += RouteManager_OnLandmarkVisited;
|
||||
App.CompassTracker.OnSlowHeadingUpdated += CompassTracker_OnHeadingUpdated;
|
||||
Settings.OnLanguageUpdate += Settings_OnLanguageUpdate;
|
||||
|
||||
Track(false);
|
||||
}
|
||||
|
||||
private void Settings_OnLanguageUpdate(EventArgs e)
|
||||
@@ -80,10 +82,9 @@ namespace NavCityBreda.Views
|
||||
{
|
||||
Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
|
||||
{
|
||||
if (Settings.Tracking && e.Heading.HeadingTrueNorth.HasValue)
|
||||
if (mapvm.Tracking && e.Heading.HeadingTrueNorth.HasValue)
|
||||
Map.TryRotateToAsync((double)e.Heading.HeadingTrueNorth);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void RouteManager_OnLandmarkVisited(object sender, LandmarkVisitedEventArgs e)
|
||||
@@ -128,13 +129,16 @@ namespace NavCityBreda.Views
|
||||
Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
if (e.Status == RouteManager.RouteStatus.STARTED)
|
||||
{
|
||||
DrawRoute();
|
||||
ZoomRoute();
|
||||
}
|
||||
else
|
||||
RemoveRoute();
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawRoute()
|
||||
private async void DrawRoute()
|
||||
{
|
||||
if (App.RouteManager.Status != RouteManager.RouteStatus.STARTED) return;
|
||||
|
||||
@@ -144,9 +148,12 @@ namespace NavCityBreda.Views
|
||||
|
||||
GeofenceMonitor.Current.Geofences.Clear();
|
||||
Map.MapElements.Clear();
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(10));
|
||||
Map.MapElements.Add(CurrentPosition);
|
||||
Map.MapElements.Add(CurrentNavigationLine);
|
||||
|
||||
Map.MapElements.Add(Util.GetRouteLine(App.RouteManager.CurrentRoute.RouteObject, Color.FromArgb(200, 100, 100, 255), 50, 3));
|
||||
|
||||
if (App.Geo.History.Count > 1)
|
||||
Map.MapElements.Add(Util.GetRouteLine(App.Geo.History.Select(p => p.Coordinate.Point.Position).ToList(), Color.FromArgb(255, 155, 155, 155), 250, 6));
|
||||
|
||||
@@ -155,59 +162,89 @@ namespace NavCityBreda.Views
|
||||
if (!l.Visited)
|
||||
GeofenceMonitor.Current.Geofences.Add(new Geofence(l.Id, new Geocircle(l.Location.Position, 35), MonitoredGeofenceStates.Entered, true));
|
||||
l.UpdateIcon();
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(3));
|
||||
Map.MapElements.Add(l.Icon);
|
||||
}
|
||||
|
||||
Map.MapElements.Add(Util.GetRouteLine(App.RouteManager.CurrentRoute.RouteObject, Color.FromArgb(200, 100, 100, 255), 50, 3));
|
||||
|
||||
ZoomRoute();
|
||||
}
|
||||
|
||||
private void RemoveRoute()
|
||||
{
|
||||
Settings.Tracking = true;
|
||||
Track(false);
|
||||
Map.MapElements.Clear();
|
||||
GeofenceMonitor.Current.Geofences.Clear();
|
||||
DrawCurrenPosition(App.Geo.Position.Coordinate.Point);
|
||||
}
|
||||
|
||||
private void DrawCurrenPosition(Geopoint p)
|
||||
{
|
||||
if (!Map.MapElements.Contains(CurrentPosition))
|
||||
{
|
||||
Map.MapElements.Add(CurrentPosition);
|
||||
Zoom();
|
||||
}
|
||||
|
||||
CurrentPosition.Location = p;
|
||||
if (Settings.Tracking)
|
||||
if (mapvm.Tracking)
|
||||
Zoom();
|
||||
}
|
||||
|
||||
private async Task<String> Zoom()
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
||||
await Map.TrySetViewAsync(CurrentPosition.Location, 17);
|
||||
if (!Zooming)
|
||||
{
|
||||
Zooming = true;
|
||||
|
||||
if(App.RouteManager.Status == RouteManager.RouteStatus.STARTED)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
||||
await Map.TryTiltToAsync(40);
|
||||
await Map.TrySetViewAsync(CurrentPosition.Location, 18);
|
||||
|
||||
if (mapvm.Tracking)
|
||||
{
|
||||
if (Map.Pitch != 55)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(300));
|
||||
await Map.TryTiltToAsync(55);
|
||||
}
|
||||
|
||||
if (App.CompassTracker.Heading.HeadingTrueNorth.HasValue)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(300));
|
||||
await Map.TryRotateToAsync((double)App.CompassTracker.Heading.HeadingTrueNorth);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Map.Pitch != 0)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(300));
|
||||
await Map.TryTiltToAsync(0);
|
||||
}
|
||||
if (Map.Heading != 0)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(300));
|
||||
await Map.TryRotateToAsync(0);
|
||||
}
|
||||
|
||||
}
|
||||
Zooming = false;
|
||||
return "success";
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
||||
await Map.TryTiltToAsync(0);
|
||||
}
|
||||
return "";
|
||||
|
||||
return "error";
|
||||
}
|
||||
|
||||
private async void ZoomRoute()
|
||||
{
|
||||
Settings.Tracking = false;
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
||||
await Map.TrySetViewBoundsAsync(App.RouteManager.CurrentRoute.Bounds, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Default);
|
||||
DisableControls(true);
|
||||
mapvm.Tracking = false;
|
||||
TrackUser.IsEnabled = false;
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(500));
|
||||
await Map.TryRotateToAsync(0);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(1500));
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(300));
|
||||
await Map.TrySetViewBoundsAsync(App.RouteManager.CurrentRoute.Bounds, null, Windows.UI.Xaml.Controls.Maps.MapAnimationKind.Default);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(1000));
|
||||
mapvm.Tracking = true;
|
||||
await Zoom();
|
||||
Settings.Tracking = true;
|
||||
TrackUser.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void Map_MapElementClick(MapControl sender, MapElementClickEventArgs args)
|
||||
@@ -225,5 +262,58 @@ namespace NavCityBreda.Views
|
||||
|
||||
App.MainPage.Navigate(typeof(LandmarkView), l);
|
||||
}
|
||||
|
||||
private void LandmarkName_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
App.MainPage.Navigate(typeof(LandmarkView), App.RouteManager.CurrentLandmark);
|
||||
}
|
||||
|
||||
private void RecalculateRoute_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
App.RouteManager.UpdateRoute();
|
||||
}
|
||||
|
||||
private void TrackUser_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Track((bool)((ToggleButton)sender).IsChecked);
|
||||
}
|
||||
|
||||
private async void Track(bool tracking)
|
||||
{
|
||||
mapvm.Tracking = tracking;
|
||||
|
||||
if(tracking)
|
||||
{
|
||||
DisableControls(true);
|
||||
|
||||
if (CurrentPosition.Location != null)
|
||||
await Zoom();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CurrentPosition.Location != null)
|
||||
await Zoom();
|
||||
|
||||
DisableControls(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableControls(bool disable)
|
||||
{
|
||||
if (disable)
|
||||
{
|
||||
Map.PanInteractionMode = MapPanInteractionMode.Disabled;
|
||||
Map.RotateInteractionMode = MapInteractionMode.Disabled;
|
||||
Map.TiltInteractionMode = MapInteractionMode.Disabled;
|
||||
Map.ZoomInteractionMode = MapInteractionMode.Disabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
Map.PanInteractionMode = MapPanInteractionMode.Auto;
|
||||
Map.RotateInteractionMode = MapInteractionMode.GestureAndControl;
|
||||
Map.TiltInteractionMode = MapInteractionMode.GestureOnly;
|
||||
Map.ZoomInteractionMode = MapInteractionMode.GestureAndControl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,14 +69,16 @@ namespace NavCityBreda.Views
|
||||
|
||||
Zoom();
|
||||
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(10));
|
||||
|
||||
MapPolyline m = Util.GetRouteLine(route.RouteObject, Color.FromArgb(255, 100, 100, 255), 25, 6);
|
||||
Map.MapElements.Add(m);
|
||||
|
||||
foreach (Landmark l in route.Landmarks)
|
||||
{
|
||||
l.UpdateIcon();
|
||||
Map.MapElements.Add(l.Icon);
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(3));
|
||||
Map.MapElements.Add(l.Icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user