mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 1.3.6: Fixed removing of OnViewportChanged handler in MapPanel and MapOverlay.
This commit is contained in:
parent
9ed0b04352
commit
da651e3e32
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@
|
|||
<!--<map:TileLayer SourceName="OSM Local Files" Description="© {y} OpenStreetMap Contributors, CC-BY-SA"
|
||||
TileSource="file:///C:/ProgramData/MapControl/TileCache/OpenStreetMap/{z}/{x}/{y}.png"/>-->
|
||||
</map:TileLayerCollection>
|
||||
<CollectionViewSource x:Key="TileLayersView" Source="{StaticResource TileLayers}"/>
|
||||
<local:LocationToVisibilityConverter x:Key="LocationToVisibilityConverter"/>
|
||||
<map:TileLayer x:Key="SeamarksTileLayer" SourceName="Seamarks" Description="© {y} OpenSeaMap Contributors, CC-BY-SA"
|
||||
TileSource="http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" MinZoomLevel="10" MaxZoomLevel="18"/>
|
||||
<CollectionViewSource x:Key="TileLayersViewSource" Source="{StaticResource TileLayers}"/>
|
||||
<local:LocationToVisibilityConverter x:Key="LocationToVisibilityConverter"/>
|
||||
<DataTemplate x:Key="PolylineItemTemplate">
|
||||
<map:MapPolyline Locations="{Binding Locations}" Stroke="Red" StrokeThickness="3"/>
|
||||
</DataTemplate>
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<map:Map Name="map" Margin="2" Center="53.5,8.2" ZoomLevel="11" MaxZoomLevel="20"
|
||||
TileLayer="{Binding Source={StaticResource TileLayersView}, Path=CurrentItem}"
|
||||
TileLayer="{Binding Source={StaticResource TileLayersViewSource}, Path=CurrentItem}"
|
||||
MouseLeftButtonDown="MapMouseLeftButtonDown" MouseRightButtonDown="MapMouseRightButtonDown"
|
||||
MouseMove="MapMouseMove" MouseLeave="MapMouseLeave"
|
||||
ManipulationInertiaStarting="MapManipulationInertiaStarting">
|
||||
|
|
@ -229,7 +229,7 @@
|
|||
</StackPanel>
|
||||
<CheckBox ToolTip="Seamarks Overlay" Margin="7" VerticalAlignment="Bottom" Content="Seamarks" Click="SeamarksClick"/>
|
||||
<ComboBox ToolTip="Tile Layer" Margin="5" VerticalAlignment="Bottom" DisplayMemberPath="SourceName"
|
||||
SelectedIndex="0" ItemsSource="{Binding Source={StaticResource TileLayersView}}"/>
|
||||
SelectedIndex="0" ItemsSource="{Binding Source={StaticResource TileLayersViewSource}}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18033
|
||||
// Runtime Version:4.0.30319.18046
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
|
|
|||
Loading…
Reference in a new issue