mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Added Heading Reset Button to sample applications
This commit is contained in:
parent
e3167b3e2c
commit
f478bf5c3b
38
SampleApps/Shared/ValueConverters.cs
Normal file
38
SampleApps/Shared/ValueConverters.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
#if WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Data;
|
||||
#else
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
#endif
|
||||
|
||||
namespace SampleApplication
|
||||
{
|
||||
public class HeadingToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return (double)value != 0d ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Convert(value, targetType, parameter, "");
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return ConvertBack(value, targetType, parameter, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
<Page
|
||||
x:Class="SampleApplication.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="using:MapControl"
|
||||
xmlns:local="using:SampleApplication">
|
||||
<Page x:Class="SampleApplication.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="using:MapControl"
|
||||
xmlns:local="using:SampleApplication">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid.Resources>
|
||||
|
|
@ -84,8 +83,8 @@
|
|||
<local:MapViewModel/>
|
||||
</Grid.DataContext>
|
||||
|
||||
<map:Map x:Name="map"
|
||||
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11" ManipulationMode="All"
|
||||
<map:Map x:Name="map" ManipulationMode="All"
|
||||
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11"
|
||||
MapLayer="{Binding MapLayers[OpenStreetMap]}"
|
||||
PointerMoved="MapPointerMoved"
|
||||
PointerExited="MapPointerExited">
|
||||
|
|
@ -131,6 +130,17 @@
|
|||
Minimum="{Binding MinZoomLevel, ElementName=map}"
|
||||
Maximum="{Binding MaxZoomLevel, ElementName=map}"
|
||||
Value="{Binding TargetZoomLevel, ElementName=map, Mode=TwoWay}"/>
|
||||
|
||||
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick">
|
||||
<Button.Visibility>
|
||||
<Binding Path="Heading" ElementName="map">
|
||||
<Binding.Converter>
|
||||
<local:HeadingToVisibilityConverter/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Button.Visibility>
|
||||
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph=""/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<Border HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace SampleApplication
|
|||
{
|
||||
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "XAML Map Control Test Application");
|
||||
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
|
||||
|
|
@ -34,6 +34,11 @@ namespace SampleApplication
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ResetHeadingButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TargetHeading = 0d;
|
||||
}
|
||||
|
||||
private void MapPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
var location = map.ViewToLocation(e.GetCurrentPoint(map).Position);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@
|
|||
<Compile Include="..\Shared\MenuButton.cs">
|
||||
<Link>MenuButton.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\ValueConverters.cs">
|
||||
<Link>ValueConverters.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
<Window
|
||||
x:Class="SampleApplication.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="using:MapControl"
|
||||
xmlns:local="using:SampleApplication">
|
||||
<Window x:Class="SampleApplication.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="using:MapControl"
|
||||
xmlns:local="using:SampleApplication">
|
||||
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
|
|
@ -85,8 +84,8 @@
|
|||
<local:MapViewModel/>
|
||||
</Grid.DataContext>
|
||||
|
||||
<map:Map x:Name="map"
|
||||
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11" MouseWheelZoomDelta="1"
|
||||
<map:Map x:Name="map" ManipulationMode="All"
|
||||
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11"
|
||||
MapLayer="{Binding MapLayers[OpenStreetMap]}"
|
||||
PointerMoved="MapPointerMoved"
|
||||
PointerExited="MapPointerExited">
|
||||
|
|
@ -132,6 +131,17 @@
|
|||
Minimum="{Binding MinZoomLevel, ElementName=map}"
|
||||
Maximum="{Binding MaxZoomLevel, ElementName=map}"
|
||||
Value="{Binding TargetZoomLevel, ElementName=map, Mode=TwoWay}"/>
|
||||
|
||||
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick">
|
||||
<Button.Visibility>
|
||||
<Binding Path="Heading" ElementName="map">
|
||||
<Binding.Converter>
|
||||
<local:HeadingToVisibilityConverter/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Button.Visibility>
|
||||
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph=""/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<Border HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace SampleApplication
|
|||
{
|
||||
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "XAML Map Control Test Application");
|
||||
|
||||
//TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
|
||||
|
|
@ -53,6 +53,11 @@ namespace SampleApplication
|
|||
await ((ImageFileCache)TileImageLoader.Cache).Clean();
|
||||
}
|
||||
|
||||
private void ResetHeadingButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TargetHeading = 0d;
|
||||
}
|
||||
|
||||
private void MapPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
var location = map.ViewToLocation(e.GetCurrentPoint(map).Position);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
xmlns:local="clr-namespace:SampleApplication"
|
||||
Title="XAML MapControl - WPF Sample Application" Height="600" Width="900"
|
||||
Stylus.IsPressAndHoldEnabled="False">
|
||||
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<DataTemplate DataType="{x:Type local:PolylineItem}">
|
||||
|
|
@ -159,6 +160,17 @@
|
|||
Value="{Binding TargetZoomLevel, ElementName=map}"
|
||||
SmallChange="0.1"
|
||||
AutoToolTipPlacement="BottomRight" AutoToolTipPrecision="0"/>
|
||||
|
||||
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
|
||||
FontSize="16" FontFamily="Segoe MDL2 Assets" Content="">
|
||||
<Button.Visibility>
|
||||
<Binding Path="Heading" ElementName="map">
|
||||
<Binding.Converter>
|
||||
<local:HeadingToVisibilityConverter/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Button.Visibility>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<local:OutlinedText
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace SampleApplication
|
|||
{
|
||||
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "XAML Map Control Test Application");
|
||||
|
||||
//TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = null;
|
||||
|
|
@ -48,6 +48,11 @@ namespace SampleApplication
|
|||
}
|
||||
}
|
||||
|
||||
private void ResetHeadingButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TargetHeading = 0d;
|
||||
}
|
||||
|
||||
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ClickCount == 2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue