mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
Reworked sample applications
This commit is contained in:
parent
9ce981a6ee
commit
32491a8e31
22 changed files with 947 additions and 706 deletions
|
|
@ -2,24 +2,15 @@
|
|||
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:map="using:MapControl"
|
||||
xmlns:local="using:SampleApplication">
|
||||
|
||||
<Grid x:Name="root">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<DataTemplate x:Key="PolylineItemTemplate">
|
||||
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="PolylineItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="AutoCollapse" Value="True"/>
|
||||
<Setter Property="LocationMemberPath" Value="Location"/>
|
||||
|
|
@ -90,32 +81,22 @@
|
|||
|
||||
</Grid.Resources>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.DataContext>
|
||||
<local:MapViewModel/>
|
||||
</Grid.DataContext>
|
||||
|
||||
<map:Map x:Name="map" ZoomLevel="11" MaxZoomLevel="21" MouseWheelZoomDelta=".5"
|
||||
Center="{Binding MapCenter}"
|
||||
MapLayer="{Binding MapLayers.CurrentMapLayer}"
|
||||
ViewportChanged="MapViewportChanged">
|
||||
<map:Map x:Name="map"
|
||||
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11" MouseWheelZoomDelta="1"
|
||||
MapLayer="{Binding MapLayers[OpenStreetMap]}"
|
||||
ViewportChanged="MapViewportChanged"
|
||||
PointerMoved="MapPointerMoved"
|
||||
PointerExited="MapPointerExited">
|
||||
<map:Map.Center>
|
||||
<map:Location Latitude="53.5" Longitude="8.2"/>
|
||||
</map:Map.Center>
|
||||
|
||||
<Image x:Name="mapImage" Source="10_535_330.jpg" Opacity="0.5" Stretch="Fill">
|
||||
<map:MapPanel.BoundingBox>
|
||||
<map:BoundingBox South="53.54031" North="53.74871" West="8.08594" East="8.43750"/>
|
||||
</map:MapPanel.BoundingBox>
|
||||
</Image>
|
||||
|
||||
<map:MapGraticule x:Name="graticule" Opacity="0.6"
|
||||
Visibility="{Binding IsChecked, ElementName=graticuleCheckBox}"/>
|
||||
|
||||
<map:MapScale HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
|
||||
|
||||
<!-- use ItemTemplate or ItemContainerStyle alternatively -->
|
||||
<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemTemplate="{StaticResource PolylineItemTemplate}"/>
|
||||
<!--<map:MapItemsControl ItemsSource="{Binding Polylines}"
|
||||
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
|
||||
|
||||
<map:MapItemsControl ItemsSource="{Binding Points}"
|
||||
ItemContainerStyle="{StaticResource PointItemStyle}"
|
||||
|
|
@ -131,23 +112,30 @@
|
|||
</map:Pushpin>
|
||||
</map:Map>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF">
|
||||
<TextBlock Margin="4,2" FontSize="10" local:HyperlinkText.InlinesSource="{Binding MapLayer.Description, ElementName=map}"/>
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<CheckBox x:Name="graticuleCheckBox"
|
||||
VerticalAlignment="Center" Content="Graticule"/>
|
||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
||||
<local:MapLayersMenuButton
|
||||
Margin="2" Padding="8" ToolTipService.ToolTip="Map Layers and Overlays"
|
||||
Map="{Binding ElementName=map}"
|
||||
MapLayers="{Binding MapLayers}"
|
||||
MapOverlays="{Binding MapOverlays}"/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Seamarks"
|
||||
Checked="SeamarksChecked" Unchecked="SeamarksUnchecked"/>
|
||||
<!--<local:MapProjectionsMenuButton
|
||||
Margin="2" Padding="8" ToolTipService.ToolTip="Map Projections"
|
||||
Map="{Binding ElementName=map}"
|
||||
MapProjections="{Binding MapProjections}"/>-->
|
||||
|
||||
<ComboBox Width="250" VerticalAlignment="Center" Margin="5"
|
||||
ItemsSource="{Binding MapLayers.MapLayerNames}"
|
||||
SelectedItem="{Binding MapLayers.CurrentMapLayerName, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Slider Orientation="Vertical" Margin="4,8" Height="100"
|
||||
Minimum="{Binding MinZoomLevel, ElementName=map}"
|
||||
Maximum="{Binding MaxZoomLevel, ElementName=map}"
|
||||
Value="{Binding TargetZoomLevel, ElementName=map, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Border HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4" Background="#AFFFFFFF">
|
||||
<TextBlock x:Name="mouseLocation" Margin="4,2" Visibility="Collapsed"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using MapControl;
|
||||
using MapControl.Caching;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
|
@ -10,8 +12,6 @@ namespace SampleApplication
|
|||
{
|
||||
public sealed partial class MainWindow : Window
|
||||
{
|
||||
private readonly MapViewModel viewModel = new();
|
||||
|
||||
static MainWindow()
|
||||
{
|
||||
try
|
||||
|
|
@ -39,8 +39,6 @@ namespace SampleApplication
|
|||
|
||||
Title = "XAML Map Control - WinUI Sample Application";
|
||||
|
||||
root.DataContext = viewModel;
|
||||
|
||||
if (TileImageLoader.Cache is ImageFileCache)
|
||||
{
|
||||
Activated += WindowActivated;
|
||||
|
|
@ -55,19 +53,42 @@ namespace SampleApplication
|
|||
await ((ImageFileCache)TileImageLoader.Cache).Clean();
|
||||
}
|
||||
|
||||
private void SeamarksChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.Children.Insert(map.Children.IndexOf(graticule), viewModel.MapLayers.SeamarksLayer);
|
||||
}
|
||||
|
||||
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.Children.Remove(viewModel.MapLayers.SeamarksLayer);
|
||||
}
|
||||
|
||||
private void MapViewportChanged(object sender, ViewportChangedEventArgs e)
|
||||
{
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
private void MapPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
var location = map.ViewToLocation(e.GetCurrentPoint(map).Position);
|
||||
var latitude = (int)Math.Round(location.Latitude * 60000d);
|
||||
var longitude = (int)Math.Round(Location.NormalizeLongitude(location.Longitude) * 60000d);
|
||||
var latHemisphere = 'N';
|
||||
var lonHemisphere = 'E';
|
||||
|
||||
if (latitude < 0)
|
||||
{
|
||||
latitude = -latitude;
|
||||
latHemisphere = 'S';
|
||||
}
|
||||
|
||||
if (longitude < 0)
|
||||
{
|
||||
longitude = -longitude;
|
||||
lonHemisphere = 'W';
|
||||
}
|
||||
|
||||
mouseLocation.Text = string.Format(CultureInfo.InvariantCulture,
|
||||
"{0} {1:00} {2:00.000}\n{3} {4:000} {5:00.000}",
|
||||
latHemisphere, latitude / 60000, (latitude % 60000) / 1000d,
|
||||
lonHemisphere, longitude / 60000, (longitude % 60000) / 1000d);
|
||||
mouseLocation.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void MapPointerExited(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
mouseLocation.Visibility = Visibility.Collapsed;
|
||||
mouseLocation.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="WinUiApp"
|
||||
Description="WinUiApp"
|
||||
DisplayName="XAML Map Control Test Application"
|
||||
Description="SampleApplication"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Shared\10_535_330.jpg" Link="10_535_330.jpg" />
|
||||
<Content Include="..\Shared\10_535_330.jpg" Link="10_535_330.jpg"/>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
|
|
|
|||
5
SampleApps/WinUiApp/WinUiApp.csproj.user
Normal file
5
SampleApps/WinUiApp/WinUiApp.csproj.user
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue