mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Avalonia sample application
This commit is contained in:
parent
f95017bdd3
commit
24b2165d0a
|
|
@ -7,12 +7,15 @@
|
|||
x:Class="SampleApplication.MainWindow"
|
||||
Title="MainWindow">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<local:MapHeadingToVisibilityConverter x:Key="MapHeadingToVisibilityConverter" />
|
||||
</Grid.Resources>
|
||||
<map:Map x:Name="map"
|
||||
ZoomLevel="11" MinZoomLevel="3"
|
||||
Center="53.5,8.2"
|
||||
DoubleTapped="OnMapDoubleTapped">
|
||||
|
||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}">
|
||||
<map:MapItemsControl ItemsSource="{Binding Pushpins}" SelectionMode="Multiple">
|
||||
<map:MapItemsControl.Styles>
|
||||
<Style Selector="map|MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
|
|
@ -25,7 +28,7 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
<Style Selector="map|MapItem[IsSelected=True]">
|
||||
<Setter Property="Foreground" Value="Red"/>
|
||||
<Setter Property="Foreground" Value="OrangeRed"/>
|
||||
</Style>
|
||||
</map:MapItemsControl.Styles>
|
||||
</map:MapItemsControl>
|
||||
|
|
@ -155,6 +158,14 @@
|
|||
Maximum="{Binding MaxZoomLevel, ElementName=map}"
|
||||
Value="{Binding TargetZoomLevel, ElementName=map}"
|
||||
SmallChange="0.1"/>
|
||||
|
||||
<Button Margin="2" Padding="8" ToolTip.Tip="Reset Heading" Click="ResetHeadingButtonClick"
|
||||
FontSize="20" FontFamily="Segoe MDL2 Assets" Content=""
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Center"
|
||||
IsVisible="{Binding ElementName=map, Path=Heading,
|
||||
Converter={StaticResource MapHeadingToVisibilityConverter}}">
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
using MapControl;
|
||||
using MapControl.UiTools;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace SampleApplication
|
||||
|
|
@ -69,8 +71,29 @@ namespace SampleApplication
|
|||
}
|
||||
|
||||
private void OnMapDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (e.Source == map)
|
||||
{
|
||||
map.TargetCenter = map.ViewToLocation(e.GetPosition(map));
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetHeadingButtonClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
map.TargetHeading = 0d;
|
||||
}
|
||||
}
|
||||
|
||||
public class MapHeadingToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (double)value != 0d;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue