XAML-Map-Control/SampleApps/AvaloniaApp/MainWindow.axaml

216 lines
13 KiB
Plaintext
Raw Normal View History

2024-05-24 15:28:28 +02:00
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:md="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia"
xmlns:map="clr-namespace:MapControl;assembly=MapControl.Avalonia"
xmlns:tools="clr-namespace:MapControl.UiTools;assembly=MapUiTools.Avalonia"
2024-05-27 11:10:10 +02:00
xmlns:local="clr-namespace:SampleApplication"
x:Class="SampleApplication.MainWindow"
2024-05-31 19:51:37 +02:00
Title="XAML MapControl - Avalonia Sample Application">
2024-05-24 15:28:28 +02:00
<Grid>
2024-05-28 18:56:28 +02:00
<Grid.Resources>
<local:MapHeadingToVisibilityConverter x:Key="MapHeadingToVisibilityConverter" />
</Grid.Resources>
2024-05-24 22:04:40 +02:00
<map:Map x:Name="map"
ZoomLevel="11" MinZoomLevel="3"
Center="53.5,8.2"
2024-05-28 22:16:29 +02:00
ManipulationModes="All"
DoubleTapped="MapDoubleTapped">
2024-05-24 15:28:28 +02:00
2024-07-04 22:24:48 +02:00
<map:MapItemsControl ItemsSource="{Binding Polylines}">
<map:MapItemsControl.ItemTemplate>
<DataTemplate>
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
</DataTemplate>
</map:MapItemsControl.ItemTemplate>
</map:MapItemsControl>
<map:MapItemsControl ItemsSource="{Binding Points}"
SelectionMode="Multiple">
<map:MapItemsControl.Styles>
<Style Selector="map|MapItem">
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
</Style>
<Style Selector="map|MapItem:selected">
<Setter Property="Foreground" Value="OrangeRed"/>
</Style>
</map:MapItemsControl.Styles>
<map:MapItemsControl.ItemTemplate>
<DataTemplate>
<Canvas Width="100" Height="100" ClipToBounds="False">
2024-07-05 13:11:37 +02:00
<Path Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=map:MapItem}}">
<Path.Data>
<EllipseGeometry RadiusX="3" RadiusY="3"/>
</Path.Data>
</Path>
2024-07-04 22:24:48 +02:00
<Path StrokeThickness="2" Stroke="Gray" Fill="Transparent">
<Path.Data>
<EllipseGeometry RadiusX="8" RadiusY="8"/>
</Path.Data>
</Path>
<TextBlock Margin="16,-9,0,0" Text="{Binding Name}"/>
</Canvas>
</DataTemplate>
</map:MapItemsControl.ItemTemplate>
</map:MapItemsControl>
2024-05-29 20:29:45 +02:00
<map:MapItemsControl ItemsSource="{Binding Pushpins}"
2024-05-31 00:08:41 +02:00
SelectedItem="{Binding SelectedPushpin}"
SelectionMode="Multiple"
SelectionChanged="MapItemsControlSelectionChanged"
DoubleTapped="MapItemsControlDoubleTapped">
2024-05-27 16:35:02 +02:00
<map:MapItemsControl.Styles>
<Style Selector="map|MapItem">
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
2024-05-31 22:29:31 +02:00
<Setter Property="AutoCollapse" Value="True"/>
2024-05-27 11:10:10 +02:00
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
2024-05-27 16:35:02 +02:00
<Setter Property="Template">
2024-07-04 22:24:48 +02:00
<ControlTemplate TargetType="map:MapItem">
<map:Pushpin Content="{Binding Name}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"/>
2024-05-27 16:35:02 +02:00
</ControlTemplate>
</Setter>
</Style>
2024-05-31 00:08:41 +02:00
<Style Selector="map|MapItem:selected">
2024-05-28 18:56:28 +02:00
<Setter Property="Foreground" Value="OrangeRed"/>
2024-05-27 11:10:10 +02:00
</Style>
2024-05-27 16:35:02 +02:00
</map:MapItemsControl.Styles>
</map:MapItemsControl>
2024-05-27 11:10:10 +02:00
2024-05-25 18:59:14 +02: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>
2024-05-25 23:03:40 +02:00
<map:MapPolygon Stroke="Yellow" StrokeThickness="2">
<map:MapPolygon.Locations>
<map:LocationCollection>53.45,8.1 53.45,8.3 53.55,8.3 53.55,8.1</map:LocationCollection>
</map:MapPolygon.Locations>
</map:MapPolygon>
2024-05-25 15:55:31 +02:00
<map:Pushpin AutoCollapse="True" Location="53.5,8.2" Content="N 53°30' E 8°12'"/>
</map:Map>
2024-05-24 15:28:28 +02:00
2024-05-25 15:55:31 +02:00
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#7FFFFFFF"
DataContext="{Binding MapLayer, ElementName=map}">
<ProgressBar Width="100" Height="8" Margin="4,2" VerticalAlignment="Center"
Maximum="1" Value="{Binding LoadingProgress}">
<ProgressBar.Styles>
<Style Selector="ProgressBar[Value=0]">
<Setter Property="IsIndeterminate" Value="True"/>
</Style>
<Style Selector="ProgressBar[Value=1]">
<Setter Property="IsVisible" Value="False"/>
</Style>
</ProgressBar.Styles>
</ProgressBar>
2024-05-24 15:28:28 +02:00
2024-05-25 15:55:31 +02:00
<LayoutTransformControl Margin="4,2">
<LayoutTransformControl.LayoutTransform>
<ScaleTransform ScaleX="0.7" ScaleY="0.7"/>
</LayoutTransformControl.LayoutTransform>
<md:MarkdownScrollViewer Markdown="{Binding Description}"/>
</LayoutTransformControl>
</StackPanel>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
<tools:MapLayersMenuButton x:Name="mapLayersMenuButton"
Margin="2" ToolTip.Tip="Map Layers and Overlays" 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="TopPlusOpen WMS Tiles">
<map:MapTileLayer
SourceName="TopPlusOpen"
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)">
<map:MapTileLayer.TileSource>
<map:BoundingBoxTileSource UriTemplate="https://sgx.geodatenzentrum.de/wms_topplus_open?SERVICE=WMS&amp;VERSION=1.3.0&amp;REQUEST=GetMap&amp;CRS=EPSG:3857&amp;LAYERS=web&amp;STYLES=&amp;FORMAT=image/png&amp;WIDTH=256&amp;HEIGHT=256&amp;BBOX={west},{south},{east},{north}"/>
</map:MapTileLayer.TileSource>
</map:MapTileLayer>
</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>
2024-05-31 14:48:59 +02:00
<tools:MapLayerItem Text="Sample Image">
<Image Source="avares://AvaloniaApp/10_535_330.jpg" Stretch="Fill"
map:MapPanel.BoundingBox="53.54031,8.08594,53.74871,8.43750"/>
2024-05-26 20:32:29 +02:00
</tools:MapLayerItem>
2024-05-31 14:48:59 +02:00
<tools:MapLayerItem Text="Mount Etna KML">
<map:GroundOverlay SourcePath="etna.kml"/>
2024-05-24 15:28:28 +02:00
</tools:MapLayerItem>
2024-05-25 15:55:31 +02:00
<tools:MapLayerItem Text="Seamarks">
2024-05-24 15:28:28 +02:00
<map:MapTileLayer
2024-05-25 15:55:31 +02:00
TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"
SourceName="Seamarks"
MinZoomLevel="9" MaxZoomLevel="18"/>
2024-05-24 15:28:28 +02:00
</tools:MapLayerItem>
2024-05-31 14:48:59 +02:00
<tools:MapLayerItem Text="Graticule">
2024-05-31 20:11:46 +02:00
<map:MapGraticule Opacity="0.7" StrokeThickness="0.25" FontSize="10"/>
2024-05-24 15:28:28 +02:00
</tools:MapLayerItem>
2024-05-31 14:48:59 +02:00
<tools:MapLayerItem Text="Scale">
<map:MapScale HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
2024-05-24 15:28:28 +02:00
</tools:MapLayerItem>
2024-05-25 15:55:31 +02:00
</tools:MapLayersMenuButton.MapOverlays>
</tools:MapLayersMenuButton>
2024-05-24 15:28:28 +02:00
2024-05-25 15:55:31 +02:00
<tools:MapProjectionsMenuButton x:Name="mapProjectionsMenuButton"
Margin="2" ToolTip.Tip="Map Projections" Map="{Binding ElementName=map}">
<tools:MapProjectionItem Text="Web Mercator" Projection="EPSG:3857"/>
<tools:MapProjectionItem Text="Equirectangular" Projection="EPSG:4326"/>
<tools:MapProjectionItem Text="ETRS89 / UTM zone 32N" Projection="EPSG:25832"/>
<tools:MapProjectionItem Text="WGS84 / Auto UTM" Projection="AUTO2:42001"/>
</tools:MapProjectionsMenuButton>
2024-05-24 22:04:40 +02:00
2024-05-25 15:55:31 +02:00
<Slider Orientation="Vertical" Margin="-4,8" Height="100"
Minimum="{Binding MinZoomLevel, ElementName=map}"
Maximum="{Binding MaxZoomLevel, ElementName=map}"
Value="{Binding TargetZoomLevel, ElementName=map}"
SmallChange="0.1"/>
2024-05-28 18:56:28 +02:00
<Button Margin="2" Padding="8" ToolTip.Tip="Reset Heading" Click="ResetHeadingButtonClick"
FontSize="20" FontFamily="Segoe MDL2 Assets" Content="&#xEBE6;"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
IsVisible="{Binding ElementName=map, Path=Heading,
Converter={StaticResource MapHeadingToVisibilityConverter}}">
</Button>
2024-05-25 15:55:31 +02:00
</StackPanel>
2024-05-24 15:28:28 +02:00
</Grid>
</Window>