XAML-Map-Control/SampleApps/UniversalApp/MainPage.xaml
2021-10-28 20:26:51 +02:00

197 lines
11 KiB
XML

<Page
x:Class="SampleApplication.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SampleApplication"
xmlns:map="using:MapControl">
<Page.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"/>
<Setter Property="FontSize" Value="12"/>
<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="PointerOver"/>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="selectedPath" Storyboard.TargetProperty="Opacity" To="0.75" Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedUnfocused">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="selectedPath" Storyboard.TargetProperty="Opacity" To="0.75" Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedPointerOver">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="selectedPath" Storyboard.TargetProperty="Opacity" To="0.75" Duration="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedPressed">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="selectedPath" Storyboard.TargetProperty="Opacity" To="0.75" Duration="0"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Path x:Name="selectedPath" Fill="White" Opacity="0">
<Path.Data>
<EllipseGeometry RadiusX="12" RadiusY="12"/>
</Path.Data>
</Path>
<Path Fill="Transparent" Stroke="Gray" StrokeThickness="2">
<Path.Data>
<EllipseGeometry RadiusX="8" RadiusY="8"/>
</Path.Data>
</Path>
<Grid Canvas.Left="15" Canvas.Top="-8">
<TextBlock Margin="2,0,2,0" Text="{Binding Name}"/>
</Grid>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
<Setter Property="AutoCollapse" Value="True"/>
<Setter Property="LocationMemberPath" Value="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>
<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"/>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<map:Map x:Name="map" MinZoomLevel="2" MaxZoomLevel="20" ZoomLevel="11" ManipulationMode="All"
Center="{x:Bind ViewModel.MapCenter, Mode=TwoWay}"
MapLayer="{x:Bind ViewModel.MapLayers.CurrentMapLayer, Mode=OneWay}"
MapProjection="{Binding SelectedValue, ElementName=projectionComboBox,
FallbackValue={StaticResource WebMercatorProjection},
TargetNullValue={StaticResource WebMercatorProjection}}">
<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}"
SelectionMode="Extended"/>
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
ItemContainerStyle="{StaticResource PushpinItemStyle}"/>
<map:Pushpin AutoCollapse="True" Content="N 53°30' E 8°12'">
<map:Pushpin.Location>
<map:Location Latitude="53.5" Longitude="8.2"/>
</map:Pushpin.Location>
</map:Pushpin>
</map:Map>
<Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#BFFFFFFF">
<TextBlock Margin="2" FontSize="10"
local:HyperlinkText.InlinesSource="{Binding MapLayers.CurrentMapLayer.Description}"/>
</Border>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel Margin="5">
<TextBlock Text="Zoom Level" HorizontalAlignment="Center" FontSize="12"/>
<Slider Margin="10,-10,10,0" Width="100" SmallChange="0.1"
Minimum="{Binding MinZoomLevel, ElementName=map}"
Maximum="{Binding MaxZoomLevel, ElementName=map}"
Value="{Binding TargetZoomLevel, ElementName=map, Mode=TwoWay}"/>
</StackPanel>
<StackPanel Margin="5">
<TextBlock Text="Heading" HorizontalAlignment="Center" FontSize="12"/>
<Slider Margin="10,-10,10,0" Width="100" Minimum="0" Maximum="360" SmallChange="5" LargeChange="45"
Value="{Binding Heading, ElementName=map, Mode=TwoWay}"/>
</StackPanel>
<StackPanel Margin="5,5,25,5">
<TextBlock Text="Image Opacity" HorizontalAlignment="Center" FontSize="12"/>
<Slider Margin="10,-10,10,0" Width="100" Value="50" ValueChanged="ImageOpacitySliderValueChanged"/>
</StackPanel>
<CheckBox x:Name="graticuleCheckBox"
VerticalAlignment="Center" Content="Graticule"/>
<CheckBox VerticalAlignment="Center" Content="Seamarks"
Checked="SeamarksChecked" Unchecked="SeamarksUnchecked"/>
<ComboBox Width="250" VerticalAlignment="Center" Margin="0,5"
ItemsSource="{Binding MapLayers.MapLayerNames}"
SelectedItem="{Binding MapLayers.CurrentMapLayerName, Mode=TwoWay}"/>
<ComboBox x:Name="projectionComboBox" Width="150" VerticalAlignment="Center" Margin="5"
SelectedIndex="0" SelectedValuePath="Tag"
SelectedValue="{Binding MapProjection, ElementName=map, Mode=TwoWay}">
<ComboBoxItem Content="Web Mercator" Tag="{StaticResource WebMercatorProjection}"/>
<ComboBoxItem Content="World Mercator" Tag="{StaticResource WorldMercatorProjection}"/>
<ComboBoxItem Content="Equirectangular" Tag="{StaticResource EquirectangularProjection}"/>
<ComboBoxItem Content="Orthographic" Tag="{StaticResource OrthographicProjection}"/>
<ComboBoxItem Content="Gnomonic" Tag="{StaticResource GnomonicProjection}"/>
<ComboBoxItem Content="Stereographic" Tag="{StaticResource StereographicProjection}"/>
</ComboBox>
</StackPanel>
</Grid>
</Grid>
</Page>