mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Version 1.3.6: Fixed removing of OnViewportChanged handler in MapPanel and MapOverlay.
This commit is contained in:
parent
9ed0b04352
commit
da651e3e32
15 changed files with 72 additions and 68 deletions
|
|
@ -388,17 +388,19 @@ namespace MapControl
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the ZoomLevel property while retaining the specified origin point
|
||||
/// Sets the value of the TargetZoomLevel property while retaining the specified origin point
|
||||
/// in viewport coordinates.
|
||||
/// </summary>
|
||||
public void ZoomMap(Point origin, double zoomLevel)
|
||||
{
|
||||
SetTransformOrigin(origin);
|
||||
|
||||
var targetZoomLevel = TargetZoomLevel;
|
||||
TargetZoomLevel = zoomLevel;
|
||||
|
||||
if (TargetZoomLevel != targetZoomLevel) // TargetZoomLevel might be coerced
|
||||
if (TargetZoomLevel == targetZoomLevel) // TargetZoomLevel might be coerced
|
||||
{
|
||||
SetTransformOrigin(origin);
|
||||
ResetTransformOrigin();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ namespace MapControl
|
|||
|
||||
private readonly DispatcherTimer updateTimer;
|
||||
private string uriFormat;
|
||||
private bool latLonBoundingBox;
|
||||
private bool updateInProgress;
|
||||
private int currentImageIndex;
|
||||
|
||||
|
|
@ -68,22 +67,16 @@ namespace MapControl
|
|||
throw new ArgumentException("UriFormat must specify the requested image size by {X} and {Y}.");
|
||||
}
|
||||
|
||||
if (value.Contains("{w}") && value.Contains("{s}") && value.Contains("{e}") && value.Contains("{n}"))
|
||||
if (!(value.Contains("{W}") && value.Contains("{S}") && value.Contains("{E}") && value.Contains("{N}")) &&
|
||||
!(value.Contains("{w}") && value.Contains("{s}") && value.Contains("{e}") && value.Contains("{n}")))
|
||||
{
|
||||
latLonBoundingBox = true;
|
||||
}
|
||||
else if (!(value.Contains("{W}") && value.Contains("{S}") && value.Contains("{E}") && value.Contains("{N}")))
|
||||
{
|
||||
throw new ArgumentException("UriFormat must specify a bounding box in meters by {W},{S},{E},{N} or as lat/lon by {w},{s},{e},{n}.");
|
||||
throw new ArgumentException("UriFormat must specify a bounding box in meters by {W},{S},{E},{N} or lat/lon by {w},{s},{e},{n}.");
|
||||
}
|
||||
}
|
||||
|
||||
uriFormat = value;
|
||||
|
||||
if (ParentMap != null)
|
||||
{
|
||||
UpdateImage(this, EventArgs.Empty);
|
||||
}
|
||||
UpdateImage(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,15 +96,7 @@ namespace MapControl
|
|||
{
|
||||
var uri = uriFormat.Replace("{X}", width.ToString()).Replace("{Y}", height.ToString());
|
||||
|
||||
if (latLonBoundingBox)
|
||||
{
|
||||
uri = uri.
|
||||
Replace("{w}", west.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{s}", south.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{e}", east.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{n}", north.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else
|
||||
if (uri.Contains("{W}") && uri.Contains("{S}") && uri.Contains("{E}") && uri.Contains("{N}"))
|
||||
{
|
||||
var p1 = ParentMap.MapTransform.Transform(new Location(south, west));
|
||||
var p2 = ParentMap.MapTransform.Transform(new Location(north, east));
|
||||
|
|
@ -123,6 +108,14 @@ namespace MapControl
|
|||
Replace("{E}", (arc * p2.X).ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{N}", (arc * p2.Y).ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else
|
||||
{
|
||||
uri = uri.
|
||||
Replace("{w}", west.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{s}", south.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{e}", east.ToString(CultureInfo.InvariantCulture)).
|
||||
Replace("{n}", north.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -156,7 +149,7 @@ namespace MapControl
|
|||
|
||||
private void UpdateImage(object sender, EventArgs e)
|
||||
{
|
||||
if (!updateInProgress)
|
||||
if (ParentMap != null && !updateInProgress)
|
||||
{
|
||||
updateTimer.Stop();
|
||||
updateInProgress = true;
|
||||
|
|
@ -179,10 +172,7 @@ namespace MapControl
|
|||
var north = Math.Max(loc1.Latitude, Math.Max(loc2.Latitude, Math.Max(loc3.Latitude, loc4.Latitude)));
|
||||
var image = GetImage(west, east, south, north, (int)width, (int)height);
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
Dispatcher.BeginInvoke((Action)(() => UpdateImage(west, east, south, north, image)));
|
||||
}
|
||||
Dispatcher.BeginInvoke((Action)(() => UpdateImage(west, east, south, north, image)));
|
||||
|
||||
updateInProgress = false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Copyright © Clemens Fischer 2012-2013
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
|
@ -170,14 +171,14 @@ namespace MapControl
|
|||
{
|
||||
if (parentMap != null)
|
||||
{
|
||||
parentMap.ViewportChanged -= (o, e) => OnViewportChanged();
|
||||
parentMap.ViewportChanged -= OnViewportChanged;
|
||||
}
|
||||
|
||||
parentMap = value;
|
||||
|
||||
if (parentMap != null)
|
||||
{
|
||||
parentMap.ViewportChanged += (o, e) => OnViewportChanged();
|
||||
parentMap.ViewportChanged += OnViewportChanged;
|
||||
OnViewportChanged();
|
||||
}
|
||||
}
|
||||
|
|
@ -225,6 +226,11 @@ namespace MapControl
|
|||
{
|
||||
}
|
||||
|
||||
private void OnViewportChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnViewportChanged();
|
||||
}
|
||||
|
||||
private void ForegroundChanged()
|
||||
{
|
||||
if (Stroke == null)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Copyright © Clemens Fischer 2012-2013
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
#if NETFX_CORE
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
|
|
@ -57,32 +58,19 @@ namespace MapControl
|
|||
{
|
||||
if (parentMap != null && parentMap != this)
|
||||
{
|
||||
parentMap.ViewportChanged -= (o, e) => OnViewportChanged();
|
||||
parentMap.ViewportChanged -= OnViewportChanged;
|
||||
}
|
||||
|
||||
parentMap = value;
|
||||
|
||||
if (parentMap != null && parentMap != this)
|
||||
{
|
||||
parentMap.ViewportChanged += (o, e) => OnViewportChanged();
|
||||
parentMap.ViewportChanged += OnViewportChanged;
|
||||
OnViewportChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnViewportChanged()
|
||||
{
|
||||
foreach (UIElement element in InternalChildren)
|
||||
{
|
||||
var location = GetLocation(element);
|
||||
|
||||
if (location != null)
|
||||
{
|
||||
SetViewportPosition(element, parentMap, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
foreach (UIElement element in InternalChildren)
|
||||
|
|
@ -110,6 +98,24 @@ namespace MapControl
|
|||
return finalSize;
|
||||
}
|
||||
|
||||
protected virtual void OnViewportChanged()
|
||||
{
|
||||
foreach (UIElement element in InternalChildren)
|
||||
{
|
||||
var location = GetLocation(element);
|
||||
|
||||
if (location != null)
|
||||
{
|
||||
SetViewportPosition(element, parentMap, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnViewportChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnViewportChanged();
|
||||
}
|
||||
|
||||
private static void ParentMapPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mapElement = obj as IMapElement;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ using System.Windows;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.3.5")]
|
||||
[assembly: AssemblyFileVersion("1.3.5")]
|
||||
[assembly: AssemblyVersion("1.3.6")]
|
||||
[assembly: AssemblyFileVersion("1.3.6")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.3.5")]
|
||||
[assembly: AssemblyFileVersion("1.3.5")]
|
||||
[assembly: AssemblyVersion("1.3.6")]
|
||||
[assembly: AssemblyFileVersion("1.3.6")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue