mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
First commit of the new XAML Map Control that replaces WPF Map Control, and now supports all three XAML platforms, WPF, Silverlight and WinRT.
This commit is contained in:
parent
c28e9d73d9
commit
27a302a5b8
124 changed files with 6938 additions and 2093 deletions
18
SampleApps/WpfApplication/App.config
Normal file
18
SampleApps/WpfApplication/App.config
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="SampleApplication.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<SampleApplication.Properties.Settings>
|
||||
<setting name="TileCache" serializeAs="String">
|
||||
<value/>
|
||||
</setting>
|
||||
</SampleApplication.Properties.Settings>
|
||||
</applicationSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
7
SampleApps/WpfApplication/App.xaml
Normal file
7
SampleApps/WpfApplication/App.xaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<Application x:Class="WpfApplication.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
8
SampleApps/WpfApplication/App.xaml.cs
Normal file
8
SampleApps/WpfApplication/App.xaml.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace WpfApplication
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
36
SampleApps/WpfApplication/LocationToVisibilityConverter.cs
Normal file
36
SampleApps/WpfApplication/LocationToVisibilityConverter.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using MapControl;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WpfApplication
|
||||
{
|
||||
public class LocationToVisibilityConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Visibility visibility = Visibility.Hidden;
|
||||
|
||||
if (values.Length == 2 && values[0] is Map && values[1] is Transform)
|
||||
{
|
||||
Map parentMap = (Map)values[0];
|
||||
Matrix transform = ((Transform)values[1]).Value;
|
||||
|
||||
if (transform.OffsetX >= 0d && transform.OffsetX <= parentMap.ActualWidth &&
|
||||
transform.OffsetY >= 0d && transform.OffsetY <= parentMap.ActualHeight)
|
||||
{
|
||||
visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
206
SampleApps/WpfApplication/MainWindow.xaml
Normal file
206
SampleApps/WpfApplication/MainWindow.xaml
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
<Window x:Class="WpfApplication.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
|
||||
xmlns:local="clr-namespace:WpfApplication"
|
||||
Title="XAML MapControl - WPF Test Application" Height="600" Width="800">
|
||||
<Window.Resources>
|
||||
<map:TileLayerCollection x:Key="TileLayers">
|
||||
<map:TileLayer SourceName="OpenStreetMap" Description="© {y} OpenStreetMap Contributors, CC-BY-SA"
|
||||
TileSource="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
||||
<map:TileLayer SourceName="OpenCycleMap" Description="OpenCycleMap - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA"
|
||||
TileSource="http://{c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png"/>
|
||||
<map:TileLayer SourceName="OCM Transport" Description="OpenCycleMap Transport - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA"
|
||||
TileSource="http://{c}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png"/>
|
||||
<map:TileLayer SourceName="OCM Landscape" Description="OpenCycleMap Landscape - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA"
|
||||
TileSource="http://{c}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png"/>
|
||||
<map:TileLayer SourceName="MapQuest OSM" Description="MapQuest OSM - © {y} MapQuest & OpenStreetMap Contributors"
|
||||
TileSource="http://otile{n}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png"/>
|
||||
|
||||
<!-- Note: The providers of the below TileLayers do not allow access to their
|
||||
map content without using their APIs (i.e. Google Maps API or Bing Maps API).
|
||||
Hence the declarations below are for demonstration purpose only. -->
|
||||
|
||||
<!--<map:TileLayer SourceName="Google Maps" Description="Google Maps - © {y} Google"
|
||||
TileSource="http://mt{i}.google.com/vt/x={x}&y={y}&z={z}" MaxZoomLevel="20"/>
|
||||
<map:TileLayer SourceName="Google Images" Description="Google Maps - © {y} Google"
|
||||
TileSource="http://khm{i}.google.com/kh/v=119&x={x}&y={y}&z={z}" MaxZoomLevel="20" HasDarkBackground="True"/>
|
||||
<map:TileLayer SourceName="Bing Maps" Description="Bing Maps - © {y} Microsoft Corporation"
|
||||
TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/r{q}.png?g=0&stl=h" MaxZoomLevel="20"/>
|
||||
<map:TileLayer SourceName="Bing Images" Description="Bing Maps - © {y} Microsoft Corporation"
|
||||
TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/a{q}.jpeg?g=0" MaxZoomLevel="20" HasDarkBackground="True"/>
|
||||
<map:TileLayer SourceName="Bing Hybrid" Description="Bing Maps - © {y} Microsoft Corporation"
|
||||
TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/h{q}.jpeg?g=0&stl=h" MaxZoomLevel="20" HasDarkBackground="True"/>-->
|
||||
|
||||
<!-- The TileLayer below uses an ImageTileSource, which bypasses caching of map tile images -->
|
||||
|
||||
<!--<map:TileLayer SourceName="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
|
||||
<map:TileLayer.TileSource>
|
||||
<map:ImageTileSource UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
|
||||
</map:TileLayer.TileSource>
|
||||
</map:TileLayer>-->
|
||||
</map:TileLayerCollection>
|
||||
<CollectionViewSource x:Key="TileLayersView" Source="{StaticResource TileLayers}"/>
|
||||
<local:LocationToVisibilityConverter x:Key="LocationToVisibilityConverter"/>
|
||||
<map:TileLayer x:Key="SeamarksTileLayer" SourceName="Seamarks" Description="© {y} OpenSeaMap Contributors, CC-BY-SA"
|
||||
TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" MinZoomLevel="10" MaxZoomLevel="18"/>
|
||||
<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="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<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="MouseOver">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="labelBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.1"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="SelectionStates">
|
||||
<VisualState x:Name="Unselected"/>
|
||||
<VisualState x:Name="Selected">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="selectedPath" Storyboard.TargetProperty="Opacity" To="0.7" Duration="0:0:0.1"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="CurrentStates">
|
||||
<VisualState x:Name="NotCurrent"/>
|
||||
<VisualState x:Name="Current">
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetName="path" Storyboard.TargetProperty="Stroke.Color" To="Magenta" Duration="0:0:0.1"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Path Name="selectedPath" Fill="White" Opacity="0">
|
||||
<Path.Data>
|
||||
<EllipseGeometry RadiusX="15" RadiusY="15"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
<Path Name="path" StrokeThickness="2" Fill="Transparent">
|
||||
<Path.Stroke>
|
||||
<SolidColorBrush Color="Gray"/>
|
||||
</Path.Stroke>
|
||||
<Path.Data>
|
||||
<EllipseGeometry RadiusX="8" RadiusY="8"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
<Grid Canvas.Left="10" Canvas.Bottom="3">
|
||||
<Rectangle Name="labelBackground" Fill="White" Opacity="0.7"/>
|
||||
<TextBlock Margin="2,0,2,1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
</Canvas>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="Visibility">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{StaticResource LocationToVisibilityConverter}">
|
||||
<Binding Path="(map:MapPanel.ParentMap)" RelativeSource="{RelativeSource Self}"/>
|
||||
<Binding Path="RenderTransform" RelativeSource="{RelativeSource Self}"/>
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<map:Pushpin Content="{Binding Name}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="OrangeRed"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<local:SampleItemCollection x:Key="Polylines"/>
|
||||
<local:SampleItemCollection x:Key="Points"/>
|
||||
<local:SampleItemCollection x:Key="Pushpins"/>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<map:Map Name="map" IsManipulationEnabled="True" Margin="2"
|
||||
LightForeground="Black" LightBackground="White" DarkForeground="White" DarkBackground="#FF3F3F3F"
|
||||
Center="53.5,8.2" ZoomLevel="11"
|
||||
TileLayer="{Binding Source={StaticResource TileLayersView}, Path=CurrentItem}"
|
||||
MouseLeftButtonDown="MapMouseLeftButtonDown" MouseRightButtonDown="MapMouseRightButtonDown"
|
||||
MouseMove="MapMouseMove" MouseLeave="MapMouseLeave"
|
||||
ManipulationInertiaStarting="MapManipulationInertiaStarting">
|
||||
<map:MapGraticule Opacity="0.6"/>
|
||||
<map:MapScale Margin="4" Opacity="0.8"/>
|
||||
|
||||
<!-- use ItemTemplate or ItemContainerStyle alternatively -->
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
ItemTemplate="{StaticResource PolylineItemTemplate}"/>
|
||||
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
|
||||
ItemContainerStyle="{StaticResource PolylineItemStyle}"/>-->
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Points}"
|
||||
ItemContainerStyle="{StaticResource PointItemStyle}"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
SelectionMode="Extended"/>
|
||||
|
||||
<map:MapItemsControl ItemsSource="{StaticResource Pushpins}"
|
||||
ItemContainerStyle="{StaticResource PushpinItemStyle}"
|
||||
IsSynchronizedWithCurrentItem="True"/>
|
||||
|
||||
<map:Pushpin map:MapPanel.Location="53.5,8.2" Background="Yellow" Foreground="Blue" Content="N 53° 30' E 8° 12'">
|
||||
<map:Pushpin.Visibility>
|
||||
<MultiBinding Converter="{StaticResource LocationToVisibilityConverter}">
|
||||
<Binding Path="(map:MapPanel.ParentMap)" RelativeSource="{RelativeSource Self}"/>
|
||||
<Binding Path="RenderTransform" RelativeSource="{RelativeSource Self}"/>
|
||||
</MultiBinding>
|
||||
</map:Pushpin.Visibility>
|
||||
</map:Pushpin>
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4" FontSize="10"
|
||||
Text="{Binding TileLayer.Description, ElementName=map}"/>
|
||||
</map:Map>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Name="mouseLocation" Margin="4" VerticalAlignment="Center"/>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Slider ToolTip="Zoom Level" Margin="4" Width="100" SmallChange="0.01"
|
||||
Minimum="{Binding MinZoomLevel, ElementName=map}"
|
||||
Maximum="{Binding MaxZoomLevel, ElementName=map}"
|
||||
Value="{Binding TargetZoomLevel, ElementName=map}"/>
|
||||
<Slider ToolTip="Heading" Margin="4" Width="100" Minimum="0" Maximum="360" SmallChange="5" LargeChange="45"
|
||||
Value="{Binding TargetHeading, ElementName=map}"/>
|
||||
<CheckBox ToolTip="Map Overlay" Margin="4" VerticalAlignment="Center" Content="Seamarks" Click="SeamarksClick"/>
|
||||
<ComboBox ToolTip="Main Tile Layer" Margin="4" DisplayMemberPath="SourceName" SelectedIndex="0"
|
||||
ItemsSource="{Binding Source={StaticResource TileLayersView}}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
177
SampleApps/WpfApplication/MainWindow.xaml.cs
Normal file
177
SampleApps/WpfApplication/MainWindow.xaml.cs
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
using Caching;
|
||||
using MapControl;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace WpfApplication
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private SamplePoint movingPoint = new SamplePoint
|
||||
{
|
||||
Name = "Moving",
|
||||
Location = new Location(53.5, 8.25)
|
||||
};
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
switch (Properties.Settings.Default.TileCache)
|
||||
{
|
||||
case "FileDbCache":
|
||||
TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheDirectory);
|
||||
break;
|
||||
case "ImageFileCache":
|
||||
TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheName, TileImageLoader.DefaultCacheDirectory);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
ICollection<object> polylines = (ICollection<object>)Resources["Polylines"];
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
|
||||
});
|
||||
polylines.Add(
|
||||
new SamplePolyline
|
||||
{
|
||||
Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
|
||||
});
|
||||
|
||||
ICollection<object> points = (ICollection<object>)Resources["Points"];
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
Location = new Location(53.51217, 8.16603)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 2",
|
||||
Location = new Location(53.50926, 8.15815)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 4",
|
||||
Location = new Location(53.50468, 8.15343)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 6",
|
||||
Location = new Location(53.50092, 8.15267)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 8",
|
||||
Location = new Location(53.49871, 8.15321)
|
||||
});
|
||||
points.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Buhne 10",
|
||||
Location = new Location(53.49350, 8.15563)
|
||||
});
|
||||
points.Add(movingPoint);
|
||||
|
||||
ICollection<object> pushpins = (ICollection<object>)Resources["Pushpins"];
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "WHV - Eckwarderhörne",
|
||||
Location = new Location(53.5495, 8.1877)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "JadeWeserPort",
|
||||
Location = new Location(53.5914, 8.14)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Kurhaus Dangast",
|
||||
Location = new Location(53.447, 8.1114)
|
||||
});
|
||||
pushpins.Add(
|
||||
new SamplePoint
|
||||
{
|
||||
Name = "Eckwarderhörne",
|
||||
Location = new Location(53.5207, 8.2323)
|
||||
});
|
||||
|
||||
DispatcherTimer timer = new DispatcherTimer();
|
||||
timer.Interval = TimeSpan.FromSeconds(0.1);
|
||||
timer.Tick += MovePoint;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void MovePoint(object sender, EventArgs e)
|
||||
{
|
||||
movingPoint.Location = new Location(movingPoint.Location.Latitude + 0.001, movingPoint.Location.Longitude + 0.002);
|
||||
|
||||
if (movingPoint.Location.Latitude > 54d)
|
||||
{
|
||||
movingPoint.Name = "Stopped";
|
||||
((DispatcherTimer)sender).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ClickCount == 2)
|
||||
{
|
||||
map.ZoomMap(e.GetPosition(map), Math.Floor(map.ZoomLevel + 1.5));
|
||||
//map.TargetCenter = map.ViewportPointToLocation(e.GetPosition(map));
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ClickCount == 2)
|
||||
{
|
||||
map.ZoomMap(e.GetPosition(map), Math.Ceiling(map.ZoomLevel - 1.5));
|
||||
}
|
||||
}
|
||||
|
||||
private void MapMouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
mouseLocation.Text = string.Empty;
|
||||
}
|
||||
|
||||
private void MapMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
mouseLocation.Text = map.ViewportPointToLocation(e.GetPosition(map)).ToString();
|
||||
}
|
||||
|
||||
private void MapManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
|
||||
{
|
||||
e.TranslationBehavior.DesiredDeceleration = 0.001;
|
||||
}
|
||||
|
||||
private void SeamarksClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var seamarks = (TileLayer)Resources["SeamarksTileLayer"];
|
||||
var checkBox = (CheckBox)sender;
|
||||
|
||||
if ((bool)checkBox.IsChecked)
|
||||
{
|
||||
map.TileLayers.Add(seamarks);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.TileLayers.Remove(seamarks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
SampleApps/WpfApplication/Properties/AssemblyInfo.cs
Normal file
16
SampleApps/WpfApplication/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
[assembly: AssemblyTitle("WpfApplication")]
|
||||
[assembly: AssemblyDescription("XAML Map Control Sample Application for WPF")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyProduct("XAML Map Control")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
||||
35
SampleApps/WpfApplication/Properties/Settings.Designer.cs
generated
Normal file
35
SampleApps/WpfApplication/Properties/Settings.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18010
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WpfApplication.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string TileCache {
|
||||
get {
|
||||
return ((string)(this["TileCache"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
SampleApps/WpfApplication/Properties/Settings.settings
Normal file
9
SampleApps/WpfApplication/Properties/Settings.settings
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SampleApplication.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="TileCache" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
51
SampleApps/WpfApplication/SampleItems.cs
Normal file
51
SampleApps/WpfApplication/SampleItems.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using MapControl;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace WpfApplication
|
||||
{
|
||||
public class SamplePoint : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
private Location location;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public Location Location
|
||||
{
|
||||
get { return location; }
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
OnPropertyChanged("Location");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SamplePolyline
|
||||
{
|
||||
public LocationCollection Locations { get; set; }
|
||||
}
|
||||
|
||||
public class SampleItemCollection : ObservableCollection<object>
|
||||
{
|
||||
}
|
||||
}
|
||||
114
SampleApps/WpfApplication/WpfApplication.csproj
Normal file
114
SampleApps/WpfApplication/WpfApplication.csproj
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{CCBCDAE5-E68F-43A8-930A-0749E476D29D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WpfApplication</RootNamespace>
|
||||
<AssemblyName>WpfApplication</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SampleItems.cs" />
|
||||
<Compile Include="LocationToVisibilityConverter.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Caching\FileDbCache\FileDbCache.csproj">
|
||||
<Project>{EF44F661-B98A-4676-927F-85D138F82300}</Project>
|
||||
<Name>FileDbCache</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Caching\ImageFileCache\ImageFileCache.csproj">
|
||||
<Project>{86470440-FEE2-4120-AF5A-3762FB9C536F}</Project>
|
||||
<Name>ImageFileCache</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\MapControl\MapControl.WPF.csproj">
|
||||
<Project>{226f3575-b683-446d-a2f0-181291dc8787}</Project>
|
||||
<Name>MapControl.WPF</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue