mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-01 02:56:55 +02:00
Version 2.10.0: Improved calculation of viewport positions.
This commit is contained in:
parent
2b66e89696
commit
c8161f2dce
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace MapControl
|
namespace MapControl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates frozen BitmapSources from Stream or Uri.
|
||||||
|
/// </summary>
|
||||||
internal static class ImageLoader
|
internal static class ImageLoader
|
||||||
{
|
{
|
||||||
public static BitmapSource FromStream(Stream stream)
|
public static BitmapSource FromStream(Stream stream)
|
||||||
|
|
|
||||||
|
|
@ -136,9 +136,15 @@ namespace MapControl
|
||||||
|
|
||||||
if (parentMap != null && location != null)
|
if (parentMap != null && location != null)
|
||||||
{
|
{
|
||||||
viewportPosition = parentMap.LocationToViewportPoint(new Location(
|
viewportPosition = parentMap.LocationToViewportPoint(location);
|
||||||
location.Latitude,
|
|
||||||
Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));
|
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))
|
if ((bool)element.GetValue(FrameworkElement.UseLayoutRoundingProperty))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,22 @@ namespace MapControl
|
||||||
|
|
||||||
private void OnViewportChanged(object sender, EventArgs e)
|
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 =
|
if (parentMap != null && location != null)
|
||||||
Location.NearestLongitude(longitude, parentMap.Center.Longitude) - longitude;
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ using System.Windows;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Interlocked.Increment(ref taskCount);
|
Interlocked.Increment(ref taskCount);
|
||||||
|
|
||||||
Task.Run(async () => await LoadPendingTiles(tileSource, sourceName));
|
Task.Run(() => LoadPendingTiles(tileSource, sourceName)); // Task.Run(Func<Task>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2015 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
using MapControl;
|
using MapControl;
|
||||||
|
|
||||||
namespace WpfApplication
|
namespace WpfApplication
|
||||||
|
|
@ -15,6 +16,17 @@ namespace WpfApplication
|
||||||
//BingMapsTileLayer.ApiKey = "...";
|
//BingMapsTileLayer.ApiKey = "...";
|
||||||
|
|
||||||
InitializeComponent();
|
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)
|
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2016 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("2.9.0")]
|
[assembly: AssemblyVersion("2.10.0")]
|
||||||
[assembly: AssemblyFileVersion("2.9.0")]
|
[assembly: AssemblyFileVersion("2.10.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue