Version 2.0:

- Support for Windows Phone 8.1 by making MapControl.WinRT a portable library
- Unified TileContainer and MapOverlay implementations across platforms
This commit is contained in:
ClemensF 2014-07-01 18:57:44 +02:00
parent ed140c6d01
commit 10527c3f0d
83 changed files with 1512 additions and 1016 deletions

View file

@ -2,7 +2,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
#if NETFX_CORE
#if WINDOWS_RUNTIME
using Windows.UI.Xaml;
#else
using System.Windows.Threading;
@ -15,11 +15,12 @@ namespace ViewModel
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
protected void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
var propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
@ -33,7 +34,7 @@ namespace ViewModel
set
{
name = value;
OnPropertyChanged("Name");
RaisePropertyChanged("Name");
}
}
@ -44,7 +45,7 @@ namespace ViewModel
set
{
location = value;
OnPropertyChanged("Location");
RaisePropertyChanged("Location");
}
}
}
@ -67,7 +68,7 @@ namespace ViewModel
set
{
mapCenter = value;
OnPropertyChanged("MapCenter");
RaisePropertyChanged("MapCenter");
}
}

View file

@ -0,0 +1,7 @@
<Application
x:Class="PhoneApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PhoneApplication">
</Application>

View file

@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
namespace PhoneApplication
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public sealed partial class App : Application
{
private TransitionCollection transitions;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += this.OnSuspending;
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
// TODO: change this value to a cache size that is appropriate for your application
rootFrame.CacheSize = 1;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// Removes the turnstile navigation for startup.
if (rootFrame.ContentTransitions != null)
{
this.transitions = new TransitionCollection();
foreach (var c in rootFrame.ContentTransitions)
{
this.transitions.Add(c);
}
}
rootFrame.ContentTransitions = null;
rootFrame.Navigated += this.RootFrame_FirstNavigated;
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}
/// <summary>
/// Restores the content transitions after the app has launched.
/// </summary>
/// <param name="sender">The object where the handler is attached.</param>
/// <param name="e">Details about the navigation event.</param>
private void RootFrame_FirstNavigated(object sender, NavigationEventArgs e)
{
var rootFrame = sender as Frame;
rootFrame.ContentTransitions = this.transitions ?? new TransitionCollection() { new NavigationThemeTransition() };
rootFrame.Navigated -= this.RootFrame_FirstNavigated;
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
// TODO: Save application state and stop any background activity
deferral.Complete();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -0,0 +1,116 @@
<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"
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>

View file

@ -0,0 +1,87 @@
using System;
using MapControl;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Navigation;
namespace PhoneApplication
{
public sealed partial class MainPage : Page
{
private bool manipulationActive;
public MainPage()
{
InitializeComponent();
DataContext = new ViewModel(Dispatcher);
NavigationCacheMode = NavigationCacheMode.Required;
}
private void SeamarksChecked(object sender, RoutedEventArgs e)
{
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
map.TileLayers.Add((TileLayer)tileLayers["Seamarks"]);
}
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
{
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
map.TileLayers.Remove((TileLayer)tileLayers["Seamarks"]);
}
private void MapMenuItemClick(object sender, RoutedEventArgs e)
{
var selectedValue = ((MenuFlyoutItem)sender).Text;
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
map.TileLayer = tileLayers[selectedValue];
}
private void CenterButtonClick(object sender, RoutedEventArgs e)
{
manipulationActive = false;
map.TargetCenter = ((ViewModel)DataContext).Location;
}
private void MapManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
manipulationActive = true;
}
private void MapManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
manipulationActive = false;
}
private void MapManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
if (manipulationActive)
{
map.TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
}
else
{
e.Complete();
}
}
}
public class ObjectReferenceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (targetType == typeof(Visibility))
{
return value != null ? Visibility.Visible : Visibility.Collapsed;
}
return value != null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotSupportedException();
}
}
}

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="45fd5832-8021-45d0-909e-dd7af206f388" Publisher="CN=Clemens" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="45fd5832-8021-45d0-909e-dd7af206f388" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>PhoneApplication</DisplayName>
<PublisherDisplayName>Clemens</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="PhoneApplication.App">
<m3:VisualElements DisplayName="PhoneApplication" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="PhoneApplication" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="location" />
</Capabilities>
</Package>

View file

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8D0A57DF-FABF-4AEE-8768-9C18B2B43CA9}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PhoneApplication</RootNamespace>
<AssemblyName>PhoneApplication</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<ProjectReference Include="..\..\MapControl\WinRT\MapControl.WinRT.csproj">
<Project>{63cefdf7-5170-43b6-86f8-5c4a383a1615}</Project>
<Name>MapControl.WinRT</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModel.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Logo.scale-240.png" />
<Content Include="Assets\SmallLogo.scale-240.png" />
<Content Include="Assets\SplashScreen.scale-240.png" />
<Content Include="Assets\Square71x71Logo.scale-240.png" />
<Content Include="Assets\StoreLogo.scale-240.png" />
<Content Include="Assets\WideLogo.scale-240.png" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == '' ">
<TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DeviceId>30F105C9-681E-420b-A277-7C086EAD8A4E</DeviceId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<DeviceId>30F105C9-681E-420b-A277-7C086EAD8A4E</DeviceId>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Windows Phone Sample Application")]
[assembly: AssemblyDescription("XAML Map Control Windows Phone Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -0,0 +1,84 @@
using System;
using System.ComponentModel;
using MapControl;
using Windows.Devices.Geolocation;
using Windows.UI.Core;
namespace PhoneApplication
{
public class ViewModel : INotifyPropertyChanged
{
private readonly CoreDispatcher dispatcher;
private readonly Geolocator geoLocator;
private double accuracy;
private Location location;
public event PropertyChangedEventHandler PropertyChanged;
public ViewModel(CoreDispatcher dispatcher)
{
this.dispatcher = dispatcher;
geoLocator = new Geolocator
{
DesiredAccuracy = PositionAccuracy.High,
MovementThreshold = 1d
};
geoLocator.StatusChanged += GeoLocatorStatusChanged;
geoLocator.PositionChanged += GeoLocatorPositionChanged;
}
public double Accuracy
{
get { return accuracy; }
private set
{
accuracy = value;
RaisePropertyChanged("Accuracy");
}
}
public Location Location
{
get { return location; }
private set
{
location = value;
RaisePropertyChanged("Location");
}
}
private void RaisePropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private async void GeoLocatorStatusChanged(Geolocator sender, StatusChangedEventArgs args)
{
if (args.Status != PositionStatus.Initializing &&
args.Status != PositionStatus.Ready)
{
await dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
{
Location = null;
});
}
}
private async void GeoLocatorPositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
await dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
{
Accuracy = args.Position.Coordinate.Accuracy;
Location = new Location(
args.Position.Coordinate.Point.Position.Latitude,
args.Position.Coordinate.Point.Position.Longitude);
});
}
}
}

View file

@ -3,13 +3,12 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Silverlight/Web Sample Application")]
[assembly: AssemblyDescription("XAML Map Control Silverlight/Web Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.12.1")]
[assembly: AssemblyFileVersion("1.12.1")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -3,13 +3,12 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Silverlight Sample Application")]
[assembly: AssemblyDescription("XAML Map Control Silverlight Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.12.1")]
[assembly: AssemblyFileVersion("1.12.1")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -2,26 +2,29 @@
x:Class="StoreApplication.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:map="using:MapControl"
xmlns:vm="using:ViewModel"
xmlns:local="using:StoreApplication"
mc:Ignorable="d">
xmlns:local="using:StoreApplication">
<Page.Resources>
<map:TileLayerCollection x:Key="TileLayers">
<map:TileLayer SourceName="OpenStreetMap" Description="© {y} OpenStreetMap Contributors, CC-BY-SA"
TileSourceUriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
<map:TileLayer SourceName="OpenCycleMap" Description="OpenCycleMap - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA"
TileSourceUriFormat="http://{c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png"/>
<map:TileLayer SourceName="OCM Transport" Description="OpenCycleMap Transport - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA"
TileSourceUriFormat="http://{c}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png"/>
<map:TileLayer SourceName="OCM Landscape" Description="OpenCycleMap Landscape - © {y} Andy Allen &amp; OpenStreetMap Contributors, CC-BY-SA"
TileSourceUriFormat="http://{c}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png"/>
<map:TileLayer SourceName="MapQuest OSM" Description="MapQuest OSM - © {y} MapQuest &amp; OpenStreetMap Contributors"
TileSourceUriFormat="http://otile{n}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png"/>
<map:TileLayer SourceName="Seamarks" Description="© {y} OpenSeaMap Contributors, CC-BY-SA"
TileSourceUriFormat="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" MinZoomLevel="10" MaxZoomLevel="18"/>
<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="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>
<DataTemplate x:Key="PolylineItemTemplate">
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
@ -180,7 +183,8 @@
<Slider Margin="10,-10,10,-10" Width="200" Value="50" ValueChanged="ImageOpacitySliderValueChanged"/>
</StackPanel>
<CheckBox Margin="10" VerticalAlignment="Center" Content="Seamarks" Checked="SeamarksChecked" Unchecked="SeamarksUnchecked"/>
<ComboBox x:Name="tileLayerComboBox" Margin="10" Width="200" VerticalAlignment="Center" SelectionChanged="TileLayerSelectionChanged">
<ComboBox Margin="10" Width="200" VerticalAlignment="Center" SelectedValuePath="Content"
Loaded="TileLayerComboBoxLoaded" SelectionChanged="TileLayerSelectionChanged">
<ComboBoxItem>OpenStreetMap</ComboBoxItem>
<ComboBoxItem>OpenCycleMap</ComboBoxItem>
<ComboBoxItem>OCM Transport</ComboBoxItem>

View file

@ -10,7 +10,6 @@ namespace StoreApplication
public MainPage()
{
this.InitializeComponent();
tileLayerComboBox.SelectedIndex = 0;
}
private void ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)
@ -21,21 +20,28 @@ namespace StoreApplication
}
}
private void TileLayerComboBoxLoaded(object sender, RoutedEventArgs e)
{
((ComboBox)sender).SelectedIndex = 0;
}
private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var comboBox = (ComboBox)sender;
var selectedValue = (string)((ComboBox)sender).SelectedValue;
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
map.TileLayer = tileLayers[(string)((ComboBoxItem)comboBox.SelectedItem).Content];
map.TileLayer = tileLayers[selectedValue];
}
private void SeamarksChecked(object sender, RoutedEventArgs e)
{
map.TileLayers.Add((TileLayer)((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
map.TileLayers.Add((TileLayer)tileLayers["Seamarks"]);
}
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
{
map.TileLayers.Remove((TileLayer)((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
map.TileLayers.Remove((TileLayer)tileLayers["Seamarks"]);
}
}
}

View file

@ -3,13 +3,12 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Windows Runtime Sample Application")]
[assembly: AssemblyDescription("XAML Map Control Windows Runtime Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.12.1")]
[assembly: AssemblyFileVersion("1.12.1")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -23,7 +23,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
<DefineConstants>TRACE;DEBUG;WINDOWS_RUNTIME</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@ -32,7 +32,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
<DefineConstants>TRACE;WINDOWS_RUNTIME</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

View file

@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.12.1")]
[assembly: AssemblyFileVersion("1.12.1")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -41,7 +41,7 @@
<!-- The following TileLayer uses an ImageTileSource, which bypasses caching of map tile images -->
<!--<map:TileLayer SourceName="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
<map:ImageTileSource UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
<map:ImageTileSource IsAsync="True" UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
</map:TileLayer>-->
<!-- The following TileLayer demonstrates how to access local tile image files (from ImageFileCache here) -->

View file

@ -3,13 +3,12 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("WPF Sample Application")]
[assembly: AssemblyDescription("XAML Map Control WPF Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.12.1")]
[assembly: AssemblyFileVersion("1.12.1")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]