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

216 lines
12 KiB
Plaintext
Raw Permalink 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: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">
2025-09-06 17:01:33 +02:00
<Window.DataContext>
<local:MapViewModel/>
</Window.DataContext>
2024-05-24 15:28:28 +02:00
<Grid>
2024-05-24 22:04:40 +02:00
<map:Map x:Name="map"
ZoomLevel="11" MinZoomLevel="3"
Center="53.5,8.2"
2025-06-12 07:41:01 +02:00
ManipulationMode="All"
2024-07-15 00:02:30 +02:00
DoubleTapped="MapDoubleTapped"
PointerPressed="MapPointerPressed"
PointerReleased="MapPointerReleased"
PointerMoved="MapPointerMoved"
PointerExited="MapPointerExited">
<map:MapPolyline x:Name="measurementLine" IsVisible="False"
Stroke="{Binding Foreground, ElementName=map}"
StrokeThickness="2" StrokeDashArray="1,1"/>
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">
2025-06-06 11:54:15 +02:00
<Setter Property="FontWeight" Value="Bold"/>
2024-07-04 22:24:48 +02:00
</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"
2025-03-22 17:11:58 +01:00
SelectionChanged="MapItemsControlSelectionChanged">
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">
2025-06-06 11:54:15 +02:00
<Setter Property="FontWeight" Value="Bold"/>
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-07-16 21:29:25 +02:00
<map:MapPath Location="53.5,8.2" Stroke="Blue" StrokeThickness="3" Fill="#1F007F00" IsHitTestVisible="False">
2024-05-25 18:59:14 +02:00
<map:MapPath.Data>
<EllipseGeometry RadiusX="1852" RadiusY="1852"/>
</map:MapPath.Data>
</map:MapPath>
2024-07-18 06:55:55 +02:00
<!--<map:MapMultiPolygon Stroke="Yellow" StrokeThickness="2" Fill="#1FFF0000" IsHitTestVisible="False">
2024-07-16 21:29:25 +02:00
<map:MapMultiPolygon.Polygons>
<map:PolygonCollection>
<map:LocationCollection>53.45,8.1 53.45,8.3 53.55,8.3 53.55,8.1</map:LocationCollection>
2024-07-18 06:55:55 +02:00
<map:LocationCollection>53.5,8.12 53.46,8.2 53.5,8.28 53.54,8.2</map:LocationCollection>
2024-07-16 21:29:25 +02:00
</map:PolygonCollection>
</map:MapMultiPolygon.Polygons>
2024-07-18 06:55:55 +02:00
</map:MapMultiPolygon>-->
2024-05-25 23:03:40 +02:00
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-07-15 00:02:30 +02:00
<TextBlock x:Name="mouseLocation"
HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4" Padding="4,2"
FontFamily="Consolas" IsHitTestVisible="False" IsVisible="False"
Foreground="{Binding Foreground, ElementName=map}">
<TextBlock.Background>
<SolidColorBrush Color="{Binding Background.Color, ElementName=map}" Opacity="0.5"/>
</TextBlock.Background>
</TextBlock>
2025-09-16 14:18:29 +02:00
<tools:MapLayerInfo MapLayer="{Binding MapLayer, ElementName=map}" Background="#AFFFFFFF"/>
2024-05-25 15:55:31 +02:00
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
2025-03-21 17:23:15 +01:00
<tools:MenuButton x:Name="mapLayersMenuButton"
Icon="&#xE81E;" Margin="2" ToolTip.Tip="Map Layers and Overlays" Map="{Binding ElementName=map}">
<tools:MapLayerMenuItem Text="OpenStreetMap">
2024-05-25 15:55:31 +02:00
<map:MapTileLayer
TileSource="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
SourceName="OpenStreetMap"
Description="© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
<tools:MapLayerMenuItem Text="OpenStreetMap German">
2024-05-25 15:55:31 +02:00
<map:MapTileLayer
2024-07-14 08:57:55 +02:00
TileSource="https://tile.openstreetmap.de/{z}/{x}/{y}.png"
2025-08-19 10:25:12 +02:00
SourceName="OpenStreetMap.de"
2024-07-14 09:36:48 +02:00
Description="© [OpenStreetMap Deutschland](https://www.openstreetmap.de) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
<tools:MapLayerMenuItem Text="OpenStreetMap French">
2024-05-25 15:55:31 +02:00
<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)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
<tools:MapLayerMenuItem Text="OpenTopoMap">
2024-05-25 15:55:31 +02:00
<map:MapTileLayer
2024-07-14 09:36:48 +02:00
TileSource="https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png"
2024-05-25 15:55:31 +02:00
SourceName="OpenTopoMap"
Description="© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
<tools:MapLayerMenuItem Text="TopPlusOpen WMTS">
2024-05-25 15:55:31 +02:00
<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)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
<tools:MapLayerMenuItem Text="TopPlusOpen WMS">
2024-05-25 15:55:31 +02:00
<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)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
<tools:MapLayerMenuItem Text="OpenStreetMap WMS">
2024-05-25 15:55:31 +02:00
<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)"/>
2025-03-21 17:23:15 +01:00
</tools:MapLayerMenuItem>
2025-03-24 19:06:15 +01:00
2025-03-21 17:23:15 +01:00
<Separator/>
2025-03-24 19:06:15 +01:00
2025-03-21 17:23:15 +01:00
<tools:MapOverlayMenuItem Text="Sample Image">
<Image Source="10_535_330.jpg" Stretch="Fill"
map:MapPanel.BoundingBox="53.54031,8.08594,53.74871,8.43750"/>
</tools:MapOverlayMenuItem>
2025-09-17 16:15:07 +02:00
<tools:MapOverlayMenuItem Text="Mount Etna KML" SourcePath="etna.kml"/>
2025-09-08 17:47:57 +02:00
<tools:MapOverlayMenuItem Text="Seamarks" InsertOrder="1">
2025-03-21 17:23:15 +01:00
<map:MapTileLayer
TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"
SourceName="Seamarks"
MinZoomLevel="9" MaxZoomLevel="18"/>
</tools:MapOverlayMenuItem>
2025-09-08 17:47:57 +02:00
<tools:MapOverlayMenuItem Text="Graticule" InsertOrder="2">
2025-06-12 07:41:01 +02:00
<map:MapGraticule Opacity="0.7" StrokeThickness="0.3"/>
2025-03-21 17:23:15 +01:00
</tools:MapOverlayMenuItem>
2025-09-08 17:47:57 +02:00
<tools:MapOverlayMenuItem Text="Scale" InsertOrder="2">
2025-03-21 17:23:15 +01:00
<map:MapScale HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
</tools:MapOverlayMenuItem>
</tools:MenuButton>
2024-05-24 15:28:28 +02:00
2025-03-21 17:23:15 +01:00
<tools:MenuButton x:Name="mapProjectionsMenuButton"
Icon="&#xE809;" Margin="2" ToolTip.Tip="Map Projections" Map="{Binding ElementName=map}">
<tools:MapProjectionMenuItem Text="Web Mercator">
EPSG:3857
</tools:MapProjectionMenuItem>
<tools:MapProjectionMenuItem Text="Equirectangular">
EPSG:4326
</tools:MapProjectionMenuItem>
<tools:MapProjectionMenuItem Text="ETRS89 / UTM zone 32N">
EPSG:25832
</tools:MapProjectionMenuItem>
</tools:MenuButton>
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"
2025-09-16 14:18:29 +02:00
HorizontalContentAlignment="Center">
<Button.IsVisible>
<Binding Path="Heading" ElementName="map">
<Binding.Converter>
<local:MapHeadingToVisibilityConverter/>
</Binding.Converter>
</Binding>
</Button.IsVisible>
2024-05-28 18:56:28 +02:00
</Button>
2024-05-25 15:55:31 +02:00
</StackPanel>
2024-05-24 15:28:28 +02:00
</Grid>
</Window>