mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01: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: 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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue