mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 1.3.3: Fixed MapImageLayer.
This commit is contained in:
parent
5d6becbb50
commit
9264cf819a
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -416,7 +416,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Loaded -= OnLoaded;
|
Loaded -= OnLoaded;
|
||||||
|
|
||||||
if (TileLayer == null)
|
if (TileLayer == null && TileLayers == null)
|
||||||
{
|
{
|
||||||
TileLayer = TileLayer.Default;
|
TileLayer = TileLayer.Default;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,12 @@ namespace MapControl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MapImageLayer : MapPanel
|
public class MapImageLayer : MapPanel
|
||||||
{
|
{
|
||||||
|
private static readonly DependencyProperty RelativeImageSizeProperty = DependencyProperty.Register(
|
||||||
|
"RelativeImageSize", typeof(double), typeof(MapImageLayer), new PropertyMetadata(1d));
|
||||||
|
|
||||||
private readonly DispatcherTimer updateTimer;
|
private readonly DispatcherTimer updateTimer;
|
||||||
private string uriFormat;
|
private string uriFormat;
|
||||||
private bool latLonBoundingBox;
|
private bool latLonBoundingBox;
|
||||||
private bool imageIsValid;
|
|
||||||
private bool updateInProgress;
|
private bool updateInProgress;
|
||||||
private int currentImageIndex;
|
private int currentImageIndex;
|
||||||
|
|
||||||
|
|
@ -43,6 +45,12 @@ namespace MapControl
|
||||||
updateTimer.Tick += UpdateImage;
|
updateTimer.Tick += UpdateImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double RelativeImageSize
|
||||||
|
{
|
||||||
|
get { return (double)GetValue(RelativeImageSizeProperty); }
|
||||||
|
set { SetValue(RelativeImageSizeProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public string UriFormat
|
public string UriFormat
|
||||||
{
|
{
|
||||||
get { return uriFormat; }
|
get { return uriFormat; }
|
||||||
|
|
@ -78,7 +86,6 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
base.OnViewportChanged();
|
base.OnViewportChanged();
|
||||||
|
|
||||||
imageIsValid = false;
|
|
||||||
updateTimer.Stop();
|
updateTimer.Stop();
|
||||||
updateTimer.Start();
|
updateTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
@ -86,6 +93,9 @@ namespace MapControl
|
||||||
protected virtual ImageSource GetImage(double west, double east, double south, double north, int width, int height)
|
protected virtual ImageSource GetImage(double west, double east, double south, double north, int width, int height)
|
||||||
{
|
{
|
||||||
ImageSource image = null;
|
ImageSource image = null;
|
||||||
|
|
||||||
|
if (uriFormat != null)
|
||||||
|
{
|
||||||
var uri = uriFormat.Replace("{X}", width.ToString()).Replace("{Y}", height.ToString());
|
var uri = uriFormat.Replace("{X}", width.ToString()).Replace("{Y}", height.ToString());
|
||||||
|
|
||||||
if (latLonBoundingBox)
|
if (latLonBoundingBox)
|
||||||
|
|
@ -134,28 +144,27 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
Trace.TraceWarning("{0}: {1}", uri, ex.Message);
|
Trace.TraceWarning("{0}: {1}", uri, ex.Message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateImage(object sender, EventArgs e)
|
private void UpdateImage(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
updateTimer.Stop();
|
if (!updateInProgress)
|
||||||
|
|
||||||
if (updateInProgress || string.IsNullOrWhiteSpace(uriFormat))
|
|
||||||
{
|
{
|
||||||
return;
|
updateTimer.Stop();
|
||||||
}
|
|
||||||
|
|
||||||
imageIsValid = true;
|
|
||||||
updateInProgress = true;
|
updateInProgress = true;
|
||||||
|
|
||||||
var loc1 = ParentMap.ViewportPointToLocation(new Point(0d, 0d));
|
var relativeSize = Math.Max(RelativeImageSize, 1d);
|
||||||
var loc2 = ParentMap.ViewportPointToLocation(new Point(ActualWidth, 0d));
|
var width = ActualWidth * relativeSize;
|
||||||
var loc3 = ParentMap.ViewportPointToLocation(new Point(0d, ActualHeight));
|
var height = ActualHeight * relativeSize;
|
||||||
var loc4 = ParentMap.ViewportPointToLocation(new Point(ActualWidth, ActualHeight));
|
var dx = (ActualWidth - width) / 2d;
|
||||||
var width = (int)ActualWidth;
|
var dy = (ActualHeight - height) / 2d;
|
||||||
var height = (int)ActualHeight;
|
var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy));
|
||||||
|
var loc2 = ParentMap.ViewportPointToLocation(new Point(width, dy));
|
||||||
|
var loc3 = ParentMap.ViewportPointToLocation(new Point(dx, height));
|
||||||
|
var loc4 = ParentMap.ViewportPointToLocation(new Point(width, height));
|
||||||
|
|
||||||
ThreadPool.QueueUserWorkItem(o =>
|
ThreadPool.QueueUserWorkItem(o =>
|
||||||
{
|
{
|
||||||
|
|
@ -163,17 +172,25 @@ namespace MapControl
|
||||||
var east = Math.Max(loc1.Longitude, Math.Max(loc2.Longitude, Math.Max(loc3.Longitude, loc4.Longitude)));
|
var east = Math.Max(loc1.Longitude, Math.Max(loc2.Longitude, Math.Max(loc3.Longitude, loc4.Longitude)));
|
||||||
var south = Math.Min(loc1.Latitude, Math.Min(loc2.Latitude, Math.Min(loc3.Latitude, loc4.Latitude)));
|
var south = Math.Min(loc1.Latitude, Math.Min(loc2.Latitude, Math.Min(loc3.Latitude, loc4.Latitude)));
|
||||||
var north = Math.Max(loc1.Latitude, Math.Max(loc2.Latitude, Math.Max(loc3.Latitude, loc4.Latitude)));
|
var north = Math.Max(loc1.Latitude, Math.Max(loc2.Latitude, Math.Max(loc3.Latitude, loc4.Latitude)));
|
||||||
var image = GetImage(west, east, south, north, width, height);
|
var image = GetImage(west, east, south, north, (int)width, (int)height);
|
||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
Dispatcher.BeginInvoke((Action)(() =>
|
Dispatcher.BeginInvoke((Action)(() => UpdateImage(west, east, south, north, image)));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateInProgress = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateImage(double west, double east, double south, double north, ImageSource image)
|
||||||
{
|
{
|
||||||
var mapImage = (MapImage)Children[currentImageIndex];
|
var mapImage = (MapImage)Children[currentImageIndex];
|
||||||
mapImage.BeginAnimation(Image.OpacityProperty,
|
mapImage.BeginAnimation(Image.OpacityProperty,
|
||||||
new DoubleAnimation
|
new DoubleAnimation
|
||||||
{
|
{
|
||||||
To = 0,
|
To = 0d,
|
||||||
Duration = Tile.AnimationDuration,
|
Duration = Tile.AnimationDuration,
|
||||||
BeginTime = Tile.AnimationDuration
|
BeginTime = Tile.AnimationDuration
|
||||||
});
|
});
|
||||||
|
|
@ -188,16 +205,6 @@ namespace MapControl
|
||||||
mapImage.North = north;
|
mapImage.North = north;
|
||||||
mapImage.Source = image;
|
mapImage.Source = image;
|
||||||
mapImage.BeginAnimation(Image.OpacityProperty, new DoubleAnimation(1d, Tile.AnimationDuration));
|
mapImage.BeginAnimation(Image.OpacityProperty, new DoubleAnimation(1d, Tile.AnimationDuration));
|
||||||
|
|
||||||
if (!imageIsValid)
|
|
||||||
{
|
|
||||||
UpdateImage(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateInProgress = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ using System.Windows;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace MapControl
|
||||||
internal partial class TileContainer
|
internal partial class TileContainer
|
||||||
{
|
{
|
||||||
private const double maxScaledTileSize = 400d; // scaled tile size 200..400 units
|
private const double maxScaledTileSize = 400d; // scaled tile size 200..400 units
|
||||||
private static double zoomLevelSwitchOffset = Math.Log(maxScaledTileSize / TileSource.TileSize, 2d);
|
private static double zoomLevelSwitchDelta = Math.Log(maxScaledTileSize / TileSource.TileSize, 2d);
|
||||||
|
|
||||||
internal static TimeSpan UpdateInterval = TimeSpan.FromSeconds(0.5);
|
internal static TimeSpan UpdateInterval = TimeSpan.FromSeconds(0.5);
|
||||||
|
|
||||||
|
|
@ -127,7 +127,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
updateTimer.Stop();
|
updateTimer.Stop();
|
||||||
|
|
||||||
var zoom = (int)Math.Floor(zoomLevel + 1d - zoomLevelSwitchOffset);
|
var zoom = (int)Math.Floor(zoomLevel + 1d - zoomLevelSwitchDelta);
|
||||||
var numTiles = 1 << zoom;
|
var numTiles = 1 << zoom;
|
||||||
var transform = GetTileIndexMatrix(numTiles);
|
var transform = GetTileIndexMatrix(numTiles);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("1.3.2")]
|
[assembly: AssemblyVersion("1.3.3")]
|
||||||
[assembly: AssemblyFileVersion("1.3.2")]
|
[assembly: AssemblyFileVersion("1.3.3")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue