XAML-Map-Control/SampleApps/PhoneApplication/MainPage.xaml

117 lines
6.7 KiB
Plaintext
Raw Normal View History

<Page
x:Class="PhoneApplication.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:map="using:MapControl"
xmlns:local="using:PhoneApplication"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<map:TileLayerCollection x:Key="TileLayers">
<map:TileLayer SourceName="OpenStreetMap" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
<map:TileSource UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
</map:TileLayer>
<map:TileLayer SourceName="OpenCycleMap" Description="OpenCycleMap - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA">
<map:TileSource UriFormat="http://{c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png"/>
</map:TileLayer>
<map:TileLayer SourceName="OCM Transport" Description="OpenCycleMap Transport - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA">
<map:TileSource UriFormat="http://{c}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png"/>
</map:TileLayer>
<map:TileLayer SourceName="OCM Landscape" Description="OpenCycleMap Landscape - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA">
<map:TileSource UriFormat="http://{c}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png"/>
</map:TileLayer>
<map:TileLayer SourceName="MapQuest OSM" Description="MapQuest OSM - © {y} MapQuest &amp; OpenStreetMap Contributors">
<map:TileSource UriFormat="http://otile{n}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png"/>
</map:TileLayer>
<map:TileLayer SourceName="Google Maps" Description="Google Maps - © {y} Google" MaxZoomLevel="20">
<map:TileSource UriFormat="http://mt{i}.google.com/vt/x={x}&amp;y={y}&amp;z={z}"/>
</map:TileLayer>
<map:TileLayer SourceName="Bing Maps" Description="Bing Maps - © {y} Microsoft Corporation" MinZoomLevel="1" MaxZoomLevel="19">
<map:TileSource UriFormat="http://ecn.t{i}.tiles.virtualearth.net/tiles/r{q}.png?g=0&amp;stl=h"/>
</map:TileLayer>
<map:TileLayer SourceName="Seamarks" Description="© {y} OpenSeaMap Contributors, CC-BY-SA" MinZoomLevel="10" MaxZoomLevel="18">
<map:TileSource UriFormat="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png"/>
</map:TileLayer>
</map:TileLayerCollection>
<local:ObjectReferenceConverter x:Key="ObjectReferenceConverter"/>
</Page.Resources>
<Grid>
<map:MapBase x:Name="map" ZoomLevel="11" MinZoomLevel="2"
ManipulationMode="Scale,TranslateX,TranslateY,TranslateInertia"
ManipulationStarted="MapManipulationStarted"
ManipulationCompleted="MapManipulationCompleted"
ManipulationDelta="MapManipulationDelta">
<map:MapBase.Center>
<map:Location Latitude="53.5" Longitude="8.2"/>
</map:MapBase.Center>
<map:MapGraticule Opacity="0.6"/>
<Canvas map:MapPanel.Location="{Binding Location}"
Visibility="{Binding Location, Converter={StaticResource ObjectReferenceConverter}}">
<Path Fill="{StaticResource PhoneAccentBrush}" Opacity="0.2">
<Path.Data>
<EllipseGeometry RadiusX="{Binding Accuracy}" RadiusY="{Binding Accuracy}"
Transform="{Binding ScaleTransform, ElementName=map}"/>
</Path.Data>
</Path>
<Path Fill="{StaticResource PhoneAccentBrush}">
<Path.Data>
<EllipseGeometry RadiusX="10" RadiusY="10"/>
</Path.Data>
</Path>
<Path Stroke="White" StrokeThickness="3">
<Path.Data>
<EllipseGeometry RadiusX="6" RadiusY="6"/>
</Path.Data>
</Path>
</Canvas>
</map:MapBase>
</Grid>
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Label="Map">
<AppBarButton.Icon>
<PathIcon Width="40" Height="40">
<PathIcon.Data>
<GeometryGroup>
<RectangleGeometry Rect="10,10,9,9"/>
<RectangleGeometry Rect="21,10,9,9"/>
<RectangleGeometry Rect="10,21,9,9"/>
<RectangleGeometry Rect="21,21,9,9"/>
</GeometryGroup>
</PathIcon.Data>
</PathIcon>
</AppBarButton.Icon>
<AppBarButton.Flyout>
<MenuFlyout>
<MenuFlyoutItem Text="OpenStreetMap" Click="MapMenuItemClick"/>
<MenuFlyoutItem Text="OpenCycleMap" Click="MapMenuItemClick"/>
<MenuFlyoutItem Text="OCM Transport" Click="MapMenuItemClick"/>
<MenuFlyoutItem Text="OCM Landscape" Click="MapMenuItemClick"/>
<MenuFlyoutItem Text="MapQuest OSM" Click="MapMenuItemClick"/>
<!--<MenuFlyoutItem Text="Google Maps" Click="MapMenuItemClick"/>
<MenuFlyoutItem Text="Bing Maps" Click="MapMenuItemClick"/>-->
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarToggleButton Label="Seamarks" Checked="SeamarksChecked" Unchecked="SeamarksUnchecked">
<AppBarToggleButton.Icon>
<PathIcon Width="40" Height="40" Data="M20,15 l5,-6 -10,0Z M20,15 l5,6 -10,0Z M21.5,23 l0,10 -3,0 0,-10Z"/>
</AppBarToggleButton.Icon>
</AppBarToggleButton>
<AppBarButton Label="Center" Click="CenterButtonClick"
IsEnabled="{Binding Location, Converter={StaticResource ObjectReferenceConverter}}">
<AppBarButton.Icon>
<PathIcon Width="40" Height="40">
<PathIcon.Data>
<GeometryGroup>
<EllipseGeometry Center="20,20" RadiusX="10" RadiusY="10"/>
<EllipseGeometry Center="20,20" RadiusX="6" RadiusY="6"/>
</GeometryGroup>
</PathIcon.Data>
</PathIcon>
</AppBarButton.Icon>
</AppBarButton>
</CommandBar>
</Page.BottomAppBar>
</Page>