Version 2.10.0: Improved calculation of viewport positions.

This commit is contained in:
ClemensF 2016-06-04 08:42:38 +02:00
parent 2b66e89696
commit c8161f2dce
17 changed files with 64 additions and 31 deletions

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -10,6 +10,9 @@ using System.Windows.Media.Imaging;
namespace MapControl
{
/// <summary>
/// Creates frozen BitmapSources from Stream or Uri.
/// </summary>
internal static class ImageLoader
{
public static BitmapSource FromStream(Stream stream)

View file

@ -136,9 +136,15 @@ namespace MapControl
if (parentMap != null && location != null)
{
viewportPosition = parentMap.LocationToViewportPoint(new Location(
location.Latitude,
Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));
viewportPosition = parentMap.LocationToViewportPoint(location);
if (viewportPosition.X < 0d || viewportPosition.X > parentMap.RenderSize.Width ||
viewportPosition.Y < 0d || viewportPosition.Y > parentMap.RenderSize.Height)
{
viewportPosition = parentMap.LocationToViewportPoint(new Location(
location.Latitude,
Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));
}
if ((bool)element.GetValue(FrameworkElement.UseLayoutRoundingProperty))
{

View file

@ -89,10 +89,22 @@ namespace MapControl
private void OnViewportChanged(object sender, EventArgs e)
{
var longitude = Location.NormalizeLongitude(MapPanel.GetLocation(this).Longitude);
var location = MapPanel.GetLocation(this);
((TranslateTransform)viewportTransform.Children[0]).X =
Location.NearestLongitude(longitude, parentMap.Center.Longitude) - longitude;
if (parentMap != null && location != null)
{
var viewportPosition = parentMap.LocationToViewportPoint(location);
var longitudeOffset = 0d;
if (viewportPosition.X < 0d || viewportPosition.X > parentMap.RenderSize.Width ||
viewportPosition.Y < 0d || viewportPosition.Y > parentMap.RenderSize.Height)
{
var longitude = Location.NormalizeLongitude(location.Longitude);
longitudeOffset = Location.NearestLongitude(longitude, parentMap.Center.Longitude) - longitude;
}
((TranslateTransform)viewportTransform.Children[0]).X = longitudeOffset;
}
}
}
}

View file

@ -14,8 +14,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -123,7 +123,7 @@ namespace MapControl
{
Interlocked.Increment(ref taskCount);
Task.Run(async () => await LoadPendingTiles(tileSource, sourceName));
Task.Run(() => LoadPendingTiles(tileSource, sourceName)); // Task.Run(Func<Task>)
}
}
}

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)]

View file

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: ComVisible(false)]

View file

@ -2,6 +2,7 @@
using System.Globalization;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using MapControl;
namespace WpfApplication
@ -15,6 +16,17 @@ namespace WpfApplication
//BingMapsTileLayer.ApiKey = "...";
InitializeComponent();
for (double lon = -180; lon < 180; lon += 10)
{
var pushpin = new Pushpin { Content = lon };
MapPanel.SetLocation(pushpin, new Location(50, lon));
map.Children.Add(pushpin);
var path = new MapPath { Data = new EllipseGeometry(new Point(lon, 60), 10, 10), Stroke = Brushes.Blue, StrokeThickness = 2 };
MapPanel.SetLocation(path, new Location(50, lon));
map.Children.Add(path);
}
}
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]