2021-10-28 20:26:51 +02:00
|
|
|
<Window x:Class="SampleApplication.MainWindow"
|
2020-03-28 21:53:38 +01:00
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
|
2022-01-11 19:42:12 +01:00
|
|
|
xmlns:tools="clr-namespace:MapControl.UiTools;assembly=MapUiTools.WPF"
|
2021-10-28 20:26:51 +02:00
|
|
|
xmlns:local="clr-namespace:SampleApplication"
|
2021-07-01 15:43:52 +02:00
|
|
|
Title="XAML MapControl - WPF Sample Application" Height="600" Width="900"
|
2020-03-28 21:53:38 +01:00
|
|
|
Stylus.IsPressAndHoldEnabled="False">
|
2021-12-06 17:54:46 +01:00
|
|
|
|
2022-01-14 00:22:41 +01:00
|
|
|
<Window.Resources>
|
|
|
|
|
<ResourceDictionary>
|
|
|
|
|
<ResourceDictionary.MergedDictionaries>
|
|
|
|
|
<ResourceDictionary Source="MapLayers.xaml"/>
|
|
|
|
|
</ResourceDictionary.MergedDictionaries>
|
|
|
|
|
|
2021-12-05 17:16:14 +01:00
|
|
|
<DataTemplate DataType="{x:Type local:PolylineItem}">
|
|
|
|
|
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
|
|
|
|
|
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
|
|
|
|
<EventSetter Event="TouchDown" Handler="MapItemTouchDown"/>
|
|
|
|
|
<Setter Property="AutoCollapse" Value="True"/>
|
|
|
|
|
<Setter Property="Location" Value="{Binding Location}"/>
|
|
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="map:MapItem">
|
|
|
|
|
<Canvas>
|
|
|
|
|
<VisualStateManager.VisualStateGroups>
|
|
|
|
|
<VisualStateGroup x:Name="CommonStates">
|
|
|
|
|
<VisualState x:Name="Normal"/>
|
|
|
|
|
<VisualState x:Name="Disabled"/>
|
|
|
|
|
<VisualState x:Name="MouseOver">
|
|
|
|
|
<Storyboard>
|
|
|
|
|
<DoubleAnimation Storyboard.TargetName="hoverPath"
|
2022-01-14 00:22:41 +01:00
|
|
|
Storyboard.TargetProperty="Opacity"
|
|
|
|
|
To="0.7" Duration="0:0:0.1"/>
|
2021-12-05 17:16:14 +01:00
|
|
|
</Storyboard>
|
|
|
|
|
</VisualState>
|
|
|
|
|
</VisualStateGroup>
|
|
|
|
|
<VisualStateGroup x:Name="SelectionStates">
|
|
|
|
|
<VisualState x:Name="Unselected"/>
|
|
|
|
|
<VisualState x:Name="Selected">
|
|
|
|
|
<Storyboard>
|
|
|
|
|
<DoubleAnimation Storyboard.TargetName="selectedPath"
|
2022-01-14 00:22:41 +01:00
|
|
|
Storyboard.TargetProperty="Opacity"
|
|
|
|
|
To="0.7" Duration="0:0:0.1"/>
|
2021-12-05 17:16:14 +01:00
|
|
|
</Storyboard>
|
|
|
|
|
</VisualState>
|
|
|
|
|
</VisualStateGroup>
|
|
|
|
|
</VisualStateManager.VisualStateGroups>
|
2023-01-21 14:41:03 +01:00
|
|
|
<!-- Path with transformed Geometry -->
|
2022-11-06 15:27:39 +01:00
|
|
|
<Path Fill="Red" Opacity="0.4" IsHitTestVisible="False">
|
|
|
|
|
<Path.Data>
|
|
|
|
|
<EllipseGeometry RadiusX="20" RadiusY="20"
|
|
|
|
|
Transform="{Binding MapTransform, RelativeSource={RelativeSource TemplatedParent}}"/>
|
|
|
|
|
</Path.Data>
|
|
|
|
|
</Path>
|
2023-01-21 14:41:03 +01:00
|
|
|
<!-- MapPath with Location -->
|
|
|
|
|
<map:MapPath Stroke="Green" StrokeThickness="2" IsHitTestVisible="False"
|
|
|
|
|
Location="{TemplateBinding Location}">
|
|
|
|
|
<map:MapPath.Data>
|
|
|
|
|
<EllipseGeometry RadiusX="20" RadiusY="20"/>
|
|
|
|
|
</map:MapPath.Data>
|
|
|
|
|
</map:MapPath>
|
2021-12-05 17:16:14 +01:00
|
|
|
<Path x:Name="selectedPath" Fill="White" Opacity="0">
|
|
|
|
|
<Path.Data>
|
|
|
|
|
<EllipseGeometry RadiusX="12" RadiusY="12"/>
|
|
|
|
|
</Path.Data>
|
|
|
|
|
</Path>
|
|
|
|
|
<Path x:Name="hoverPath" StrokeThickness="6" Stroke="White" Opacity="0">
|
|
|
|
|
<Path.Data>
|
|
|
|
|
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
|
|
|
|
</Path.Data>
|
|
|
|
|
</Path>
|
|
|
|
|
<Path StrokeThickness="2" Stroke="Gray" Fill="Transparent">
|
|
|
|
|
<Path.Data>
|
|
|
|
|
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
|
|
|
|
</Path.Data>
|
|
|
|
|
</Path>
|
|
|
|
|
<Grid Canvas.Left="15" Canvas.Top="-8">
|
2023-01-05 15:37:43 +01:00
|
|
|
<TextBlock Margin="2,0" Text="{Binding Name}"/>
|
2021-12-05 17:16:14 +01:00
|
|
|
</Grid>
|
|
|
|
|
</Canvas>
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<Trigger Property="IsSelected" Value="True">
|
|
|
|
|
<Setter Property="Panel.ZIndex" Value="1"/>
|
|
|
|
|
</Trigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
|
|
|
|
|
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
|
|
|
|
<EventSetter Event="TouchDown" Handler="MapItemTouchDown"/>
|
|
|
|
|
<Setter Property="AutoCollapse" Value="True"/>
|
|
|
|
|
<Setter Property="Location" Value="{Binding Location}"/>
|
2022-02-01 22:21:30 +01:00
|
|
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
2021-12-05 17:16:14 +01:00
|
|
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
|
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="map:MapItem">
|
2022-02-01 22:21:30 +01:00
|
|
|
<map:Pushpin Content="{Binding Name}"
|
|
|
|
|
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"/>
|
2021-12-05 17:16:14 +01:00
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<Trigger Property="IsSelected" Value="True">
|
|
|
|
|
<Setter Property="Panel.ZIndex" Value="1"/>
|
|
|
|
|
<Setter Property="Foreground" Value="OrangeRed"/>
|
|
|
|
|
</Trigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
2022-01-14 00:22:41 +01:00
|
|
|
</ResourceDictionary>
|
|
|
|
|
</Window.Resources>
|
2021-12-05 17:16:14 +01:00
|
|
|
|
2022-01-18 23:59:12 +01:00
|
|
|
<Window.DataContext>
|
|
|
|
|
<local:MapViewModel/>
|
|
|
|
|
</Window.DataContext>
|
2022-01-13 20:12:49 +01:00
|
|
|
|
2022-01-18 23:59:12 +01:00
|
|
|
<Grid>
|
2021-12-05 17:43:05 +01:00
|
|
|
<map:Map x:Name="map"
|
2022-11-12 01:14:07 +01:00
|
|
|
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11"
|
2022-11-12 18:34:54 +01:00
|
|
|
Center="53.5,8.2" ManipulationMode="All"
|
2017-06-25 23:05:48 +02:00
|
|
|
MouseLeftButtonDown="MapMouseLeftButtonDown"
|
2022-12-02 23:15:09 +01:00
|
|
|
MouseRightButtonDown="MapMouseRightButtonDown"
|
2023-01-06 16:01:03 +01:00
|
|
|
MouseRightButtonUp="MapMouseRightButtonUp"
|
|
|
|
|
MouseMove="MapMouseMove"
|
|
|
|
|
MouseLeave="MapMouseLeave"
|
2012-11-22 21:42:29 +01:00
|
|
|
ManipulationInertiaStarting="MapManipulationInertiaStarting">
|
2013-05-07 18:12:25 +02:00
|
|
|
|
2023-01-06 16:01:03 +01:00
|
|
|
<map:MapPolyline x:Name="measurementLine" Visibility="Collapsed"
|
|
|
|
|
Stroke="{Binding Foreground, ElementName=map}"
|
|
|
|
|
StrokeThickness="2" StrokeDashArray="1,1"/>
|
|
|
|
|
|
2021-12-05 17:16:14 +01:00
|
|
|
<map:MapItemsControl ItemsSource="{Binding Polylines}"/>
|
2012-11-22 21:42:29 +01:00
|
|
|
|
2013-11-17 16:52:03 +01:00
|
|
|
<map:MapItemsControl ItemsSource="{Binding Points}"
|
2012-06-14 10:43:27 +02:00
|
|
|
ItemContainerStyle="{StaticResource PointItemStyle}"
|
2012-11-22 21:42:29 +01:00
|
|
|
SelectionMode="Extended"/>
|
|
|
|
|
|
2013-11-17 16:52:03 +01:00
|
|
|
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
|
2019-06-04 22:03:25 +02:00
|
|
|
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
|
2012-11-22 21:42:29 +01:00
|
|
|
|
2021-01-13 00:08:55 +01:00
|
|
|
<map:Pushpin AutoCollapse="True" Location="65,-18" Content="Iceland"/>
|
|
|
|
|
<map:Pushpin AutoCollapse="True" Location="71,25" Content="Norway"/>
|
|
|
|
|
<map:Pushpin AutoCollapse="True" Location="35,33" Content="Cyprus"/>
|
|
|
|
|
<map:Pushpin AutoCollapse="True" Location="28.25,-16.5" Content="Tenerife"/>
|
2017-06-25 23:05:48 +02:00
|
|
|
|
2021-01-13 20:54:17 +01:00
|
|
|
<map:MapPath Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00">
|
2020-03-28 21:53:38 +01:00
|
|
|
<map:MapPath.Data>
|
|
|
|
|
<EllipseGeometry RadiusX="1852" RadiusY="1852"/>
|
|
|
|
|
</map:MapPath.Data>
|
|
|
|
|
</map:MapPath>
|
2014-11-19 21:11:14 +01:00
|
|
|
|
2021-01-17 21:39:42 +01:00
|
|
|
<map:Pushpin AutoCollapse="True" Location="53.5,8.2" Content="N 53°30' E 8°12'"/>
|
2012-05-04 12:52:20 +02:00
|
|
|
</map:Map>
|
2014-11-19 21:11:14 +01:00
|
|
|
|
2023-01-05 15:37:43 +01:00
|
|
|
<TextBlock x:Name="mouseLocation"
|
|
|
|
|
HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4" Padding="4,2"
|
|
|
|
|
FontFamily="Consolas" IsHitTestVisible="False" Visibility="Collapsed"
|
|
|
|
|
Foreground="{Binding Foreground, ElementName=map}">
|
|
|
|
|
<TextBlock.Background>
|
|
|
|
|
<SolidColorBrush Color="{Binding Background.Color, ElementName=map}" Opacity="0.5"/>
|
|
|
|
|
</TextBlock.Background>
|
|
|
|
|
</TextBlock>
|
2022-08-06 15:06:10 +02:00
|
|
|
|
2022-08-05 22:56:00 +02:00
|
|
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF"
|
|
|
|
|
DataContext="{Binding MapLayer, ElementName=map}">
|
2022-08-06 15:06:10 +02:00
|
|
|
<ProgressBar Width="100" Height="8" Margin="4,2" VerticalAlignment="Center"
|
|
|
|
|
Maximum="1" Value="{Binding LoadingProgress}">
|
2022-08-05 18:54:19 +02:00
|
|
|
<ProgressBar.Style>
|
|
|
|
|
<Style TargetType="ProgressBar">
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<Trigger Property="Value" Value="0">
|
|
|
|
|
<Setter Property="IsIndeterminate" Value="True"/>
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="Value" Value="1">
|
|
|
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
|
|
|
</Trigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</ProgressBar.Style>
|
|
|
|
|
</ProgressBar>
|
|
|
|
|
|
2022-08-05 22:56:00 +02:00
|
|
|
<TextBlock Margin="4,2" FontSize="10" local:HyperlinkText.InlinesSource="{Binding Description}"/>
|
2022-08-05 18:54:19 +02:00
|
|
|
</StackPanel>
|
2014-11-19 21:11:14 +01:00
|
|
|
|
2021-12-05 17:16:14 +01:00
|
|
|
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
2022-01-13 20:12:49 +01:00
|
|
|
<tools:MapLayersMenuButton x:Name="mapLayersMenuButton"
|
2022-01-24 23:07:36 +01:00
|
|
|
Margin="2" ToolTip="Map Layers and Overlays"
|
2022-01-13 20:12:49 +01:00
|
|
|
Map="{Binding ElementName=map}">
|
2022-01-14 00:22:41 +01:00
|
|
|
<tools:MapLayerItem Text="OpenStreetMap" Layer="{StaticResource OpenStreetMap}"/>
|
|
|
|
|
<tools:MapLayerItem Text="OpenStreetMap German" Layer="{StaticResource OpenStreetMapGerman}"/>
|
|
|
|
|
<tools:MapLayerItem Text="OpenStreetMap French" Layer="{StaticResource OpenStreetMapFrench}"/>
|
|
|
|
|
<tools:MapLayerItem Text="OpenTopoMap" Layer="{StaticResource OpenTopoMap}"/>
|
|
|
|
|
<tools:MapLayerItem Text="TopPlusOpen WMTS" Layer="{StaticResource TopPlusOpenWMTS}"/>
|
|
|
|
|
<tools:MapLayerItem Text="TopPlusOpen WMS" Layer="{StaticResource TopPlusOpenWMS}"/>
|
|
|
|
|
<tools:MapLayerItem Text="OpenStreetMap WMS" Layer="{StaticResource OpenStreetMapWMS}"/>
|
2022-01-13 20:12:49 +01:00
|
|
|
<tools:MapLayersMenuButton.MapOverlays>
|
2022-12-14 18:02:19 +01:00
|
|
|
<tools:MapLayerItem Text="Graticule">
|
|
|
|
|
<map:MapGraticule Opacity="0.7"/>
|
|
|
|
|
</tools:MapLayerItem>
|
|
|
|
|
<tools:MapLayerItem Text="Scale">
|
|
|
|
|
<map:MapScale HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
|
|
|
|
|
</tools:MapLayerItem>
|
|
|
|
|
<tools:MapLayerItem Text="Seamarks" Layer="{StaticResource Seamarks}"/>
|
2022-02-19 18:51:15 +01:00
|
|
|
<tools:MapLayerItem Text="Sample Image">
|
2022-11-04 23:46:54 +01:00
|
|
|
<Image Source="10_535_330.jpg" Stretch="Fill"
|
|
|
|
|
map:MapPanel.BoundingBox="53.54031,8.08594,53.74871,8.43750"/>
|
2022-02-19 18:51:15 +01:00
|
|
|
</tools:MapLayerItem>
|
2022-12-05 23:34:30 +01:00
|
|
|
<tools:MapLayerItem Text="Mount Etna KML">
|
|
|
|
|
<map:GroundOverlay SourcePath="etna.kml"/>
|
|
|
|
|
</tools:MapLayerItem>
|
2022-01-13 20:12:49 +01:00
|
|
|
</tools:MapLayersMenuButton.MapOverlays>
|
|
|
|
|
</tools:MapLayersMenuButton>
|
2021-12-05 17:16:14 +01:00
|
|
|
|
2022-01-13 20:12:49 +01:00
|
|
|
<tools:MapProjectionsMenuButton x:Name="mapProjectionsMenuButton"
|
2022-01-24 23:07:36 +01:00
|
|
|
Margin="2" ToolTip="Map Projections"
|
2022-01-13 20:12:49 +01:00
|
|
|
Map="{Binding ElementName=map}">
|
2022-01-19 23:42:45 +01:00
|
|
|
<tools:MapProjectionItem Text="Web Mercator" Projection="EPSG:3857"/>
|
|
|
|
|
<tools:MapProjectionItem Text="Equirectangular" Projection="EPSG:4326"/>
|
2022-12-14 18:02:19 +01:00
|
|
|
<tools:MapProjectionItem Text="ETRS89 / UTM zone 32N" Projection="EPSG:25832"/>
|
|
|
|
|
<tools:MapProjectionItem Text="WGS84 / Auto UTM" Projection="AUTO2:42001"/>
|
2022-01-13 20:12:49 +01:00
|
|
|
</tools:MapProjectionsMenuButton>
|
2021-12-05 17:16:14 +01:00
|
|
|
|
|
|
|
|
<Slider Orientation="Vertical" Margin="8" Height="100"
|
|
|
|
|
Minimum="{Binding MinZoomLevel, ElementName=map}"
|
|
|
|
|
Maximum="{Binding MaxZoomLevel, ElementName=map}"
|
|
|
|
|
Value="{Binding TargetZoomLevel, ElementName=map}"
|
|
|
|
|
SmallChange="0.1"
|
|
|
|
|
AutoToolTipPlacement="BottomRight" AutoToolTipPrecision="0"/>
|
2021-12-06 17:54:46 +01:00
|
|
|
|
2022-01-24 23:07:36 +01:00
|
|
|
<Button Margin="2" Padding="8" ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
|
|
|
|
|
FontSize="20" FontFamily="Segoe MDL2 Assets" Content="">
|
2022-08-05 18:54:19 +02:00
|
|
|
<Button.Style>
|
|
|
|
|
<Style TargetType="Button">
|
|
|
|
|
<Style.Triggers>
|
|
|
|
|
<DataTrigger Binding="{Binding Heading, ElementName=map}" Value="0">
|
|
|
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</Button.Style>
|
2021-12-06 17:54:46 +01:00
|
|
|
</Button>
|
2021-12-05 17:16:14 +01:00
|
|
|
</StackPanel>
|
2012-05-04 12:52:20 +02:00
|
|
|
</Grid>
|
|
|
|
|
</Window>
|