XAML-Map-Control/SampleApps/WpfApplication/MainWindow.xaml

247 lines
14 KiB
Plaintext
Raw Normal View History

2021-10-28 20:26:51 +02:00
<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="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"
Stylus.IsPressAndHoldEnabled="False">
2021-12-05 17:16:14 +01:00
<Grid>
<Grid.Resources>
<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"
2021-01-17 21:39:42 +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"
2021-01-17 21:39:42 +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>
<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">
<local:OutlinedText Margin="1" OutlineThickness="1.5" Text="{Binding Name}"
2021-01-17 21:39:42 +01:00
Background="{Binding Background, RelativeSource={RelativeSource AncestorType=map:MapBase}}"/>
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}"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="map:MapItem">
<map:Pushpin Content="{Binding Name}"/>
</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>
<map:WebMercatorProjection x:Key="WebMercatorProjection"/>
<map:WorldMercatorProjection x:Key="WorldMercatorProjection"/>
<map:EquirectangularProjection x:Key="EquirectangularProjection"/>
<map:OrthographicProjection x:Key="OrthographicProjection"/>
<map:GnomonicProjection x:Key="GnomonicProjection"/>
<map:StereographicProjection x:Key="StereographicProjection"/>
</Grid.Resources>
<Grid.DataContext>
<local:MapViewModel/>
</Grid.DataContext>
2022-01-13 20:12:49 +01:00
2021-12-05 17:43:05 +01:00
<map:Map x:Name="map"
MinZoomLevel="2" MaxZoomLevel="21" ZoomLevel="11" MouseWheelZoomDelta="1"
2021-12-05 17:16:14 +01:00
Center="53.5,8.2"
MouseLeftButtonDown="MapMouseLeftButtonDown"
MouseRightButtonDown="MapMouseRightButtonDown"
MouseMove="MapMouseMove" MouseLeave="MapMouseLeave"
ManipulationInertiaStarting="MapManipulationInertiaStarting">
2021-12-05 17:16:14 +01:00
<map:MapItemsControl ItemsSource="{Binding Polylines}"/>
<map:MapItemsControl ItemsSource="{Binding Points}"
ItemContainerStyle="{StaticResource PointItemStyle}"
SelectionMode="Extended"/>
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
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"/>
2021-01-13 20:54:17 +01:00
<map:MapPath Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00">
<map:MapPath.Data>
<EllipseGeometry RadiusX="1852" RadiusY="1852"/>
</map:MapPath.Data>
</map:MapPath>
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>
2020-10-25 16:09:09 +01:00
<Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF">
2021-12-05 17:16:14 +01:00
<TextBlock Margin="4,2" FontSize="10"
local:HyperlinkText.InlinesSource="{Binding MapLayer.Description, ElementName=map}"/>
</Border>
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"
2021-12-05 17:16:14 +01:00
Margin="2" Padding="6" FontSize="16" ToolTip="Map Layers and Overlays"
2022-01-13 20:12:49 +01:00
Map="{Binding ElementName=map}">
<tools:MapLayerItem Text="OpenStreetMap">
<map:MapTileLayer
TileSource="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
SourceName="OpenStreetMap"
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
</tools:MapLayerItem>
<tools:MapLayerItem Text="OpenStreetMap German">
<map:MapTileLayer
TileSource="https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png"
SourceName="OpenStreetMap German"
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
</tools:MapLayerItem>
<tools:MapLayerItem Text="OpenStreetMap French">
<map:MapTileLayer
TileSource="http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png"
SourceName="OpenStreetMap French"
Description="© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
</tools:MapLayerItem>
<tools:MapLayerItem Text="OpenTopoMap">
<map:MapTileLayer
TileSource="https://tile.opentopomap.org/{z}/{x}/{y}.png"
SourceName="OpenTopoMap"
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
</tools:MapLayerItem>
<tools:MapLayerItem Text="TopPlusOpen WMTS">
<map:WmtsTileLayer
CapabilitiesUri="https://sgx.geodatenzentrum.de/wmts_topplus_open/1.0.0/WMTSCapabilities.xml"
SourceName="TopPlusOpen"
Description="© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wmts-topplusopen-wmts-topplus-open.html)"/>
</tools:MapLayerItem>
<tools:MapLayerItem Text="TopPlusOpen WMS">
<map:WmsImageLayer
ServiceUri="https://sgx.geodatenzentrum.de/wms_topplus_open"
Description="© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wms-topplusopen-mit-layer-fur-normalausgabe-und-druck-wms-topplus-open.html)"/>
</tools:MapLayerItem>
<tools:MapLayerItem Text="OpenStreetMap WMS">
<map:WmsImageLayer
ServiceUri="http://ows.terrestris.de/osm/service"
Description="© [terrestris GmbH &amp; Co. KG](http://ows.terrestris.de/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
</tools:MapLayerItem>
<tools:MapLayersMenuButton.MapOverlays>
<tools:MapLayerItem Text="Seamarks">
<map:MapTileLayer
TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"
SourceName="Seamarks"
MinZoomLevel="9"
MaxZoomLevel="18"/>
</tools:MapLayerItem>
<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="Sample Image">
<Image Source="10_535_330.jpg" map:MapPanel.BoundingBox="53.54031,8.08594,53.74871,8.43750"/>
</tools:MapLayerItem>
</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"
2021-12-05 17:16:14 +01:00
Margin="2" Padding="6" FontSize="16" ToolTip="Map Projections"
2022-01-13 20:12:49 +01:00
Map="{Binding ElementName=map}">
<tools:MapProjectionItem Text="Web Mercator">
<map:WebMercatorProjection/>
</tools:MapProjectionItem>
<tools:MapProjectionItem Text="Equirectangular">
<map:EquirectangularProjection/>
</tools:MapProjectionItem>
</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"/>
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
FontSize="16" FontFamily="Segoe MDL2 Assets" Content="&#xEBE6;">
<Button.Visibility>
<Binding Path="Heading" ElementName="map">
<Binding.Converter>
<local:HeadingToVisibilityConverter/>
</Binding.Converter>
</Binding>
</Button.Visibility>
</Button>
2021-12-05 17:16:14 +01:00
</StackPanel>
<local:OutlinedText
x:Name="mouseLocation" Margin="4"
Background="{Binding Background, ElementName=map}"
Foreground="{Binding Foreground, ElementName=map}"
2021-12-05 18:30:58 +01:00
HorizontalAlignment="Center" VerticalAlignment="Top"
IsHitTestVisible="False"/>
2012-05-04 12:52:20 +02:00
</Grid>
</Window>