diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index c22cc179..75a45f2a 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index 244d27ac..f44ac956 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index 391e3f9a..ad16a8fd 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -405,6 +405,27 @@ namespace MapControl } } + /// + /// Sets the TargetZoomLevel and TargetCenter properties such that the specified bounding box + /// fits into the current viewport. The TargetHeading property is set to zero. + /// + public void ZoomToBounds(Location southWest, Location northEast) + { + if (southWest.Latitude < northEast.Latitude && southWest.Longitude < northEast.Longitude) + { + var p1 = MapTransform.Transform(southWest); + var p2 = MapTransform.Transform(northEast); + var lonScale = ActualWidth / (p2.X - p1.X) * 360d / TileSource.TileSize; + var latScale = ActualHeight / (p2.Y - p1.Y) * 360d / TileSource.TileSize; + var lonZoom = Math.Log(lonScale, 2d); + var latZoom = Math.Log(latScale, 2d); + + TargetZoomLevel = Math.Min(lonZoom, latZoom); + TargetCenter = MapTransform.Transform(new Point((p1.X + p2.X) / 2d, (p1.Y + p2.Y) / 2d)); + TargetHeading = 0d; + } + } + protected override void OnViewportChanged() { base.OnViewportChanged(); @@ -551,8 +572,14 @@ namespace MapControl internalPropertyChange = false; } - private bool CoerceLocation(Location location, double latitudeEpsilon = 0d) + private bool CoerceLocation(ref Location location, double latitudeEpsilon = 0d) { + if (location == null) + { + location = new Location(); + return true; + } + var maxLatitude = mapTransform.MaxLatitude + latitudeEpsilon; var latitude = Math.Min(Math.Max(location.Latitude, -maxLatitude), maxLatitude); var longitude = Location.NormalizeLongitude(location.Longitude); @@ -567,9 +594,9 @@ namespace MapControl return false; } - private void CoerceCenterProperty(DependencyProperty property, Location center) + private void CoerceCenterProperty(DependencyProperty property, ref Location center) { - if (CoerceLocation(center)) + if (CoerceLocation(ref center)) { InternalSetValue(property, center); } @@ -579,7 +606,7 @@ namespace MapControl { if (!internalPropertyChange) { - CoerceCenterProperty(CenterProperty, center); + CoerceCenterProperty(CenterProperty, ref center); ResetTransformOrigin(); UpdateTransform(); @@ -595,9 +622,9 @@ namespace MapControl { if (!internalPropertyChange) { - CoerceCenterProperty(TargetCenterProperty, targetCenter); + CoerceCenterProperty(TargetCenterProperty, ref targetCenter); - if (!targetCenter.Equals(Center)) + if (targetCenter.Latitude != Center.Latitude || targetCenter.Longitude != Center.Longitude) { if (centerAnimation != null) { @@ -652,9 +679,11 @@ namespace MapControl if (coercedValue != minZoomLevel) { - InternalSetValue(MinZoomLevelProperty, coercedValue); + minZoomLevel = coercedValue; + InternalSetValue(MinZoomLevelProperty, minZoomLevel); } - else if (ZoomLevel < minZoomLevel) + + if (ZoomLevel < minZoomLevel) { ZoomLevel = minZoomLevel; } @@ -666,32 +695,32 @@ namespace MapControl if (coercedValue != maxZoomLevel) { - InternalSetValue(MaxZoomLevelProperty, coercedValue); + maxZoomLevel = coercedValue; + InternalSetValue(MaxZoomLevelProperty, maxZoomLevel); } - else if (ZoomLevel > maxZoomLevel) + + if (ZoomLevel > maxZoomLevel) { ZoomLevel = maxZoomLevel; } } - private bool CoerceZoomLevelProperty(DependencyProperty property, ref double zoomLevel) + private void CoerceZoomLevelProperty(DependencyProperty property, ref double zoomLevel) { var coercedValue = Math.Min(Math.Max(zoomLevel, MinZoomLevel), MaxZoomLevel); if (coercedValue != zoomLevel) { - InternalSetValue(property, coercedValue); - return true; + zoomLevel = coercedValue; + InternalSetValue(property, zoomLevel); } - - return false; } private void ZoomLevelPropertyChanged(double zoomLevel) { - if (!internalPropertyChange && - !CoerceZoomLevelProperty(ZoomLevelProperty, ref zoomLevel)) + if (!internalPropertyChange) { + CoerceZoomLevelProperty(ZoomLevelProperty, ref zoomLevel); UpdateTransform(); if (zoomLevelAnimation == null) @@ -703,25 +732,28 @@ namespace MapControl private void TargetZoomLevelPropertyChanged(double targetZoomLevel) { - if (!internalPropertyChange && - !CoerceZoomLevelProperty(TargetZoomLevelProperty, ref targetZoomLevel) && - targetZoomLevel != ZoomLevel) + if (!internalPropertyChange) { - if (zoomLevelAnimation != null) + CoerceZoomLevelProperty(TargetZoomLevelProperty, ref targetZoomLevel); + + if (targetZoomLevel != ZoomLevel) { - zoomLevelAnimation.Completed -= ZoomLevelAnimationCompleted; + if (zoomLevelAnimation != null) + { + zoomLevelAnimation.Completed -= ZoomLevelAnimationCompleted; + } + + zoomLevelAnimation = new DoubleAnimation + { + To = targetZoomLevel, + Duration = AnimationDuration, + EasingFunction = AnimationEasingFunction, + FillBehavior = FillBehavior.HoldEnd + }; + + zoomLevelAnimation.Completed += ZoomLevelAnimationCompleted; + this.BeginAnimation(ZoomLevelProperty, zoomLevelAnimation); } - - zoomLevelAnimation = new DoubleAnimation - { - To = targetZoomLevel, - Duration = AnimationDuration, - EasingFunction = AnimationEasingFunction, - FillBehavior = FillBehavior.HoldEnd - }; - - zoomLevelAnimation.Completed += ZoomLevelAnimationCompleted; - this.BeginAnimation(ZoomLevelProperty, zoomLevelAnimation); } } @@ -742,12 +774,12 @@ namespace MapControl private void CoerceHeadingProperty(DependencyProperty property, ref double heading) { - var coercedValue = (heading >= -180d && heading <= 360d) ? - heading : (((heading % 360d) + 360d) % 360d); + var coercedValue = (heading >= -180d && heading <= 360d) ? heading : (((heading % 360d) + 360d) % 360d); if (coercedValue != heading) { - InternalSetValue(property, coercedValue); + heading = coercedValue; + InternalSetValue(property, heading); } } @@ -826,7 +858,7 @@ namespace MapControl { center = ViewportPointToLocation(new Point(RenderSize.Width / 2d, RenderSize.Height / 2d)); - var coerced = CoerceLocation(center, 1e-3); + var coerced = CoerceLocation(ref center, 1e-3); InternalSetValue(CenterProperty, center); diff --git a/MapControl/MapGraticule.Silverlight.WinRT.cs b/MapControl/MapGraticule.Silverlight.WinRT.cs index 50e0b5b7..9d6599bc 100644 --- a/MapControl/MapGraticule.Silverlight.WinRT.cs +++ b/MapControl/MapGraticule.Silverlight.WinRT.cs @@ -226,7 +226,6 @@ namespace MapControl { for (var lon = labelsStart.Longitude; lon <= end.Longitude; lon += spacing) { - var location = new Location(lat, lon); TextBlock label; if (childIndex < Children.Count) @@ -273,13 +272,17 @@ namespace MapControl { transformGroup.Children.Add(new TranslateTransform()); transformGroup.Children.Add(ParentMap.RotateTransform); + transformGroup.Children.Add(new TranslateTransform()); } var translateTransform = (TranslateTransform)transformGroup.Children[0]; translateTransform.X = StrokeThickness / 2d + 2d; translateTransform.Y = -label.DesiredSize.Height / 2d; - MapPanel.SetLocation(label, location); + var viewportPosition = ParentMap.LocationToViewportPoint(new Location(lat, lon)); + translateTransform = (TranslateTransform)transformGroup.Children[2]; + translateTransform.X = viewportPosition.X; + translateTransform.Y = viewportPosition.Y; } } diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs index 234aa69c..b8f0eb4d 100644 --- a/MapControl/MapPanel.cs +++ b/MapControl/MapPanel.cs @@ -151,6 +151,23 @@ namespace MapControl if (parentMap != null && location != null) { + var longitude = Location.NormalizeLongitude(location.Longitude); + var centerDistance = longitude - parentMap.Center.Longitude; + + if (centerDistance > 180d) + { + longitude -= 360d; + } + else if (centerDistance < -180d) + { + longitude += 360d; + } + + if (location.Longitude != longitude) // keep viewport position near map center + { + location = new Location(location.Latitude, longitude); + } + viewportPosition = parentMap.LocationToViewportPoint(location); element.SetValue(ViewportPositionProperty, viewportPosition); } diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 39d82727..095b20b5 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -15,8 +15,8 @@ using System.Windows; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/TileContainer.Silverlight.WinRT.cs b/MapControl/TileContainer.Silverlight.WinRT.cs index 3be445ed..22da03c5 100644 --- a/MapControl/TileContainer.Silverlight.WinRT.cs +++ b/MapControl/TileContainer.Silverlight.WinRT.cs @@ -17,8 +17,10 @@ namespace MapControl { internal partial class TileContainer : Panel { - private Matrix GetViewportTransformMatrix(Matrix transform) + private Matrix GetViewportTransformMatrix(double scale, double offsetX, double offsetY) { + var transform = new Matrix(scale, 0d, 0d, -scale, offsetX, offsetY); + return transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y); } diff --git a/MapControl/TileContainer.WPF.cs b/MapControl/TileContainer.WPF.cs index 9a87e1c4..dc9a415b 100644 --- a/MapControl/TileContainer.WPF.cs +++ b/MapControl/TileContainer.WPF.cs @@ -9,8 +9,10 @@ namespace MapControl { internal partial class TileContainer : ContainerVisual { - private Matrix GetViewportTransformMatrix(Matrix transform) + private Matrix GetViewportTransformMatrix(double scale, double offsetX, double offsetY) { + var transform = new Matrix(scale, 0d, 0d, -scale, offsetX, offsetY); + transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y); return transform; diff --git a/MapControl/TileContainer.cs b/MapControl/TileContainer.cs index 667789bf..054bd91f 100644 --- a/MapControl/TileContainer.cs +++ b/MapControl/TileContainer.cs @@ -101,7 +101,7 @@ namespace MapControl tileLayerOffset.X = transformOffsetX - 180d * scale; tileLayerOffset.Y = transformOffsetY - 180d * scale; - ViewportTransform.Matrix = GetViewportTransformMatrix(new Matrix(scale, 0d, 0d, -scale, transformOffsetX, transformOffsetY)); + ViewportTransform.Matrix = GetViewportTransformMatrix(scale, transformOffsetX, transformOffsetY); if (Math.Sign(mapOrigin.X) != Math.Sign(oldMapOriginX) && Math.Abs(mapOrigin.X) > 90d) { diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index cfac5dec..8ae081a3 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -104,7 +104,7 @@ namespace MapControl return; } } - else if (!tileSource.UriFormat.StartsWith("file:")) // always load local image files asynchronously + else if (!tileSource.UriFormat.StartsWith("file:")) // load local image files asynchronously, without caching { if (Cache == null || string.IsNullOrWhiteSpace(sourceName)) { @@ -183,7 +183,7 @@ namespace MapControl if (uri != null) { - if (uri.Scheme == "file") + if (uri.Scheme == "file") // create from FileStream as creating from URI leaves the file open { image = CreateImage(uri.AbsolutePath); } @@ -256,7 +256,7 @@ namespace MapControl { try { - using (var stream = new FileStream(path, FileMode.Open)) + using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { image = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); } diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 615c8bac..e68f0649 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -48,7 +48,7 @@ namespace MapControl public TileLayer() { - MinZoomLevel = 1; + MinZoomLevel = 0; MaxZoomLevel = 18; MaxParallelDownloads = 8; LoadLowerZoomLevels = true; diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index be2f4f21..948f3dc3 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -145,6 +145,11 @@ namespace MapControl private Uri GetQuadKeyUri(int x, int y, int zoomLevel) { + if (zoomLevel < 1) + { + return null; + } + var key = new StringBuilder { Length = zoomLevel }; for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2) diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index e3f48ad2..1cdf1020 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/10_535_330.jpg b/SampleApps/Common/10_535_330.jpg similarity index 100% rename from SampleApps/SilverlightApplication/10_535_330.jpg rename to SampleApps/Common/10_535_330.jpg diff --git a/SampleApps/Common/ViewModel.cs b/SampleApps/Common/ViewModel.cs new file mode 100644 index 00000000..5b18d00d --- /dev/null +++ b/SampleApps/Common/ViewModel.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +#if NETFX_CORE +using Windows.UI.Xaml; +#else +using System.Windows.Threading; +#endif +using MapControl; + +namespace ViewModel +{ + public class VmBase : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged(string propertyName) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } + + public class VmPoint : VmBase + { + private string name; + public string Name + { + get { return name; } + set + { + name = value; + OnPropertyChanged("Name"); + } + } + + private Location location; + public Location Location + { + get { return location; } + set + { + location = value; + OnPropertyChanged("Location"); + } + } + } + + public class VmPolyline + { + public LocationCollection Locations { get; set; } + } + + public class ViewModel : VmBase + { + public ObservableCollection Points { get; set; } + public ObservableCollection Pushpins { get; set; } + public ObservableCollection Polylines { get; set; } + + private Location mapCenter; + public Location MapCenter + { + get { return mapCenter; } + set + { + mapCenter = value; + OnPropertyChanged("MapCenter"); + } + } + + public ViewModel() + { + MapCenter = new Location(53.5, 8.2); + + Points = new ObservableCollection(); + Points.Add( + new VmPoint + { + Name = "Steinbake Leitdamm", + Location = new Location(53.51217, 8.16603) + }); + Points.Add( + new VmPoint + { + Name = "Buhne 2", + Location = new Location(53.50926, 8.15815) + }); + Points.Add( + new VmPoint + { + Name = "Buhne 4", + Location = new Location(53.50468, 8.15343) + }); + Points.Add( + new VmPoint + { + Name = "Buhne 6", + Location = new Location(53.50092, 8.15267) + }); + Points.Add( + new VmPoint + { + Name = "Buhne 8", + Location = new Location(53.49871, 8.15321) + }); + Points.Add( + new VmPoint + { + Name = "Buhne 10", + Location = new Location(53.49350, 8.15563) + }); + Points.Add( + new VmPoint + { + Name = "Moving", + Location = new Location(53.5, 8.25) + }); + + Pushpins = new ObservableCollection(); + Pushpins.Add( + new VmPoint + { + Name = "WHV - Eckwarderhörne", + Location = new Location(53.5495, 8.1877) + }); + Pushpins.Add( + new VmPoint + { + Name = "JadeWeserPort", + Location = new Location(53.5914, 8.14) + }); + Pushpins.Add( + new VmPoint + { + Name = "Kurhaus Dangast", + Location = new Location(53.447, 8.1114) + }); + Pushpins.Add( + new VmPoint + { + Name = "Eckwarderhörne", + Location = new Location(53.5207, 8.2323) + }); + + //for (double lon = -720; lon <= 720; lon += 15) + //{ + // var lat = lon / 10; + // Pushpins.Add( + // new VmPoint + // { + // Name = string.Format("{0:00.0}°, {1:000}°", lat, lon), + // Location = new Location(lat, lon) + // }); + //} + + Polylines = new ObservableCollection(); + Polylines.Add( + new VmPolyline + { + 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 VmPolyline + { + 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") + }); + + var timer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(0.1) + }; + + timer.Tick += (sender, e) => + { + var p = Points.Last(); + p.Location = new Location(p.Location.Latitude + 0.001, p.Location.Longitude + 0.002); + + if (p.Location.Latitude > 54d) + { + p.Name = "Stopped"; + ((DispatcherTimer)sender).Stop(); + } + }; + + timer.Start(); + } + } +} diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index 4d0e3823..35521462 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/MainPage.xaml b/SampleApps/SilverlightApplication/MainPage.xaml index 1901d701..734127a4 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml +++ b/SampleApps/SilverlightApplication/MainPage.xaml @@ -4,8 +4,9 @@ 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="clr-namespace:MapControl;assembly=MapControl.Silverlight" xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:map="clr-namespace:MapControl;assembly=MapControl.Silverlight" + xmlns:vm="clr-namespace:ViewModel" xmlns:local="clr-namespace:SilverlightApplication" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> @@ -93,32 +94,32 @@ - - - + + + - - - - - diff --git a/SampleApps/SilverlightApplication/MainPage.xaml.cs b/SampleApps/SilverlightApplication/MainPage.xaml.cs index e8008c0a..5b09b9ce 100644 --- a/SampleApps/SilverlightApplication/MainPage.xaml.cs +++ b/SampleApps/SilverlightApplication/MainPage.xaml.cs @@ -1,118 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using System.Windows.Threading; using MapControl; namespace SilverlightApplication { public partial class MainPage : UserControl { - private SamplePoint movingPoint = new SamplePoint - { - Name = "Moving", - Location = new Location(53.5, 8.25) - }; - public MainPage() { InitializeComponent(); tileLayerComboBox.SelectedIndex = 0; - - var polylines = (ICollection)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") - }); - - var points = (ICollection)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); - - var pushpins = (ICollection)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) - }); - - var timer = new DispatcherTimer { 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 MapMouseLeave(object sender, MouseEventArgs e) diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 56c8f888..cd747fbf 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/SampleItems.cs b/SampleApps/SilverlightApplication/SampleItems.cs deleted file mode 100644 index bbfe90dc..00000000 --- a/SampleApps/SilverlightApplication/SampleItems.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.ObjectModel; -using System.ComponentModel; -using MapControl; - -namespace SilverlightApplication -{ - 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 - { - } -} diff --git a/SampleApps/SilverlightApplication/SilverlightApplication.csproj b/SampleApps/SilverlightApplication/SilverlightApplication.csproj index c6af4cfe..95f33178 100644 --- a/SampleApps/SilverlightApplication/SilverlightApplication.csproj +++ b/SampleApps/SilverlightApplication/SilverlightApplication.csproj @@ -73,6 +73,9 @@ + + ViewModel.cs + App.xaml @@ -80,7 +83,6 @@ MainPage.xaml - @@ -108,7 +110,9 @@ - + + 10_535_330.jpg + - - - - diff --git a/SampleApps/StoreApplication/MainPage.xaml.cs b/SampleApps/StoreApplication/MainPage.xaml.cs index 66aa9794..91f63616 100644 --- a/SampleApps/StoreApplication/MainPage.xaml.cs +++ b/SampleApps/StoreApplication/MainPage.xaml.cs @@ -1,121 +1,16 @@ -using System; -using System.Collections.Generic; -using MapControl; +using MapControl; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; -// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 - namespace StoreApplication { - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// public sealed partial class MainPage : Page { - private SamplePoint movingPoint = new SamplePoint - { - Name = "Moving", - Location = new Location(53.5, 8.25) - }; - public MainPage() { this.InitializeComponent(); tileLayerComboBox.SelectedIndex = 0; - - var polylines = (ICollection)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") - }); - - var points = (ICollection)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); - - var pushpins = (ICollection)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) - }); - - var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) }; - timer.Tick += MovePoint; - timer.Start(); - } - - private void MovePoint(object sender, object 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 ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e) diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index 9f0d38a2..39f46008 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/SampleItems.cs b/SampleApps/StoreApplication/SampleItems.cs deleted file mode 100644 index 04769ee2..00000000 --- a/SampleApps/StoreApplication/SampleItems.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.ObjectModel; -using System.ComponentModel; -using MapControl; - -namespace StoreApplication -{ - 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 - { - } -} diff --git a/SampleApps/StoreApplication/StoreApplication.csproj b/SampleApps/StoreApplication/StoreApplication.csproj index 17bbd195..50fce977 100644 --- a/SampleApps/StoreApplication/StoreApplication.csproj +++ b/SampleApps/StoreApplication/StoreApplication.csproj @@ -37,6 +37,9 @@ 4 + + ViewModel.cs + App.xaml @@ -45,7 +48,6 @@ MainPage.xaml - @@ -53,7 +55,9 @@ - + + 10_535_330.jpg + diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs index 96b900ec..c9a8dc51 100644 --- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/10_535_330.jpg b/SampleApps/WpfApplication/10_535_330.jpg deleted file mode 100644 index 7eb2f5a7..00000000 Binary files a/SampleApps/WpfApplication/10_535_330.jpg and /dev/null differ diff --git a/SampleApps/WpfApplication/App.config b/SampleApps/WpfApplication/App.config index 25b1eb77..aed15bcc 100644 --- a/SampleApps/WpfApplication/App.config +++ b/SampleApps/WpfApplication/App.config @@ -8,7 +8,7 @@ - + ImageFileCache diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index 64e4ba7f..7833c4dc 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -1,11 +1,17 @@ - + + - + TileSource="http://ecn.t{i}.tiles.virtualearth.net/tiles/h{q}.jpeg?g=0&stl=h" MaxZoomLevel="20"/> - - - - diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index 8d0fb6da..f36414d7 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -1,11 +1,9 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.Runtime.Caching; using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using System.Windows.Threading; using Caching; using MapControl; @@ -13,12 +11,6 @@ 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) @@ -37,98 +29,6 @@ namespace WpfApplication } InitializeComponent(); - - var polylines = (ICollection)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") - }); - - var points = (ICollection)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); - - var pushpins = (ICollection)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) - }); - - var timer = new DispatcherTimer { 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) @@ -171,6 +71,13 @@ namespace WpfApplication e.TranslationBehavior.DesiredDeceleration = 0.001; } + private void MapItemTouchDown(object sender, TouchEventArgs e) + { + var mapItem = (MapItem)sender; + mapItem.IsSelected = !mapItem.IsSelected; + e.Handled = true; + } + private void SeamarksClick(object sender, RoutedEventArgs e) { var seamarks = (TileLayer)Resources["SeamarksTileLayer"]; diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index 216b6127..e3cf2aba 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -8,8 +8,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("1.8.0")] -[assembly: AssemblyFileVersion("1.8.0")] +[assembly: AssemblyVersion("1.9.0")] +[assembly: AssemblyFileVersion("1.9.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/Properties/Settings.Designer.cs b/SampleApps/WpfApplication/Properties/Settings.Designer.cs index 5fcde2a0..c601f6e5 100644 --- a/SampleApps/WpfApplication/Properties/Settings.Designer.cs +++ b/SampleApps/WpfApplication/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34003 +// Runtime Version:4.0.30319.18408 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -25,7 +25,7 @@ namespace WpfApplication.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.DefaultSettingValueAttribute("ImageFileCache")] public string TileCache { get { return ((string)(this["TileCache"])); diff --git a/SampleApps/WpfApplication/Properties/Settings.settings b/SampleApps/WpfApplication/Properties/Settings.settings index 0dab5ee7..d4515930 100644 --- a/SampleApps/WpfApplication/Properties/Settings.settings +++ b/SampleApps/WpfApplication/Properties/Settings.settings @@ -3,7 +3,7 @@ - + ImageFileCache \ No newline at end of file diff --git a/SampleApps/WpfApplication/SampleItems.cs b/SampleApps/WpfApplication/SampleItems.cs deleted file mode 100644 index a3bc5236..00000000 --- a/SampleApps/WpfApplication/SampleItems.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.ObjectModel; -using System.ComponentModel; -using MapControl; - -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 - { - } -} diff --git a/SampleApps/WpfApplication/WpfApplication.csproj b/SampleApps/WpfApplication/WpfApplication.csproj index 78ba97a8..b1d94675 100644 --- a/SampleApps/WpfApplication/WpfApplication.csproj +++ b/SampleApps/WpfApplication/WpfApplication.csproj @@ -49,7 +49,10 @@ MSBuild:Compile Designer - + + ViewModel.cs + + MSBuild:Compile Designer @@ -97,7 +100,9 @@ - + + 10_535_330.jpg +