mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 1.12.1: Some cleanup and minor improvements.
This commit is contained in:
parent
4f37eaa914
commit
ed140c6d01
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileDbCache", "Caching\FileDbCache\FileDbCache.csproj", "{EF44F661-B98A-4676-927F-85D138F82300}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageFileCache", "Caching\ImageFileCache\ImageFileCache.csproj", "{86470440-FEE2-4120-AF5A-3762FB9C536F}"
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class Map : MapBase
|
||||
{
|
||||
public static readonly DependencyProperty MouseWheelZoomChangeProperty = DependencyProperty.Register(
|
||||
"MouseWheelZoomChange", typeof(double), typeof(Map), new PropertyMetadata(1d));
|
||||
public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
|
||||
"MouseWheelZoomDelta", typeof(double), typeof(Map), new PropertyMetadata(1d));
|
||||
|
||||
private Point? mousePosition;
|
||||
|
||||
|
|
@ -28,15 +28,15 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
|
||||
/// </summary>
|
||||
public double MouseWheelZoomChange
|
||||
public double MouseWheelZoomDelta
|
||||
{
|
||||
get { return (double)GetValue(MouseWheelZoomChangeProperty); }
|
||||
set { SetValue(MouseWheelZoomChangeProperty, value); }
|
||||
get { return (double)GetValue(MouseWheelZoomDeltaProperty); }
|
||||
set { SetValue(MouseWheelZoomDeltaProperty, value); }
|
||||
}
|
||||
|
||||
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
var zoomChange = MouseWheelZoomChange * (double)e.Delta / 120d;
|
||||
var zoomChange = MouseWheelZoomDelta * (double)e.Delta / 120d;
|
||||
ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomChange);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ namespace MapControl
|
|||
public static readonly DependencyProperty ManipulationModeProperty = DependencyProperty.Register(
|
||||
"ManipulationMode", typeof(ManipulationModes), typeof(Map), new PropertyMetadata(ManipulationModes.All));
|
||||
|
||||
public static readonly DependencyProperty MouseWheelZoomChangeProperty = DependencyProperty.Register(
|
||||
"MouseWheelZoomChange", typeof(double), typeof(Map), new PropertyMetadata(1d));
|
||||
public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
|
||||
"MouseWheelZoomDelta", typeof(double), typeof(Map), new PropertyMetadata(1d));
|
||||
|
||||
private Point? mousePosition;
|
||||
|
||||
|
|
@ -37,18 +37,18 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
|
||||
/// </summary>
|
||||
public double MouseWheelZoomChange
|
||||
public double MouseWheelZoomDelta
|
||||
{
|
||||
get { return (double)GetValue(MouseWheelZoomChangeProperty); }
|
||||
set { SetValue(MouseWheelZoomChangeProperty, value); }
|
||||
get { return (double)GetValue(MouseWheelZoomDeltaProperty); }
|
||||
set { SetValue(MouseWheelZoomDeltaProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseWheelEventArgs e)
|
||||
{
|
||||
base.OnMouseWheel(e);
|
||||
|
||||
var zoomChange = MouseWheelZoomChange * (double)e.Delta / 120d;
|
||||
ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomChange);
|
||||
var zoomDelta = MouseWheelZoomDelta * (double)e.Delta / 120d;
|
||||
ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomDelta);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
|
|
@ -79,7 +79,7 @@ namespace MapControl
|
|||
if (mousePosition.HasValue)
|
||||
{
|
||||
var position = e.GetPosition(this);
|
||||
TranslateMap((Point)(position - mousePosition));
|
||||
TranslateMap((Point)(position - mousePosition.Value));
|
||||
mousePosition = position;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public class Map : MapBase
|
||||
{
|
||||
public static readonly DependencyProperty MouseWheelZoomChangeProperty = DependencyProperty.Register(
|
||||
"MouseWheelZoomChange", typeof(double), typeof(Map), new PropertyMetadata(1d));
|
||||
public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
|
||||
"MouseWheelZoomDelta", typeof(double), typeof(Map), new PropertyMetadata(1d));
|
||||
|
||||
private Point? mousePosition;
|
||||
|
||||
|
|
@ -36,16 +36,16 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
|
||||
/// </summary>
|
||||
public double MouseWheelZoomChange
|
||||
public double MouseWheelZoomDelta
|
||||
{
|
||||
get { return (double)GetValue(MouseWheelZoomChangeProperty); }
|
||||
set { SetValue(MouseWheelZoomChangeProperty, value); }
|
||||
get { return (double)GetValue(MouseWheelZoomDeltaProperty); }
|
||||
set { SetValue(MouseWheelZoomDeltaProperty, value); }
|
||||
}
|
||||
|
||||
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
var point = e.GetCurrentPoint(this);
|
||||
var zoomChange = MouseWheelZoomChange * (double)point.Properties.MouseWheelDelta / 120d;
|
||||
var zoomChange = MouseWheelZoomDelta * (double)point.Properties.MouseWheelDelta / 120d;
|
||||
ZoomMap(point.Position, TargetZoomLevel + zoomChange);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace MapControl
|
|||
|
||||
private void OnRenderSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
((RectangleGeometry)Clip).Rect = new Rect(0d, 0d, RenderSize.Width, RenderSize.Height);
|
||||
((RectangleGeometry)Clip).Rect = new Rect(new Point(), e.NewSize);
|
||||
ResetTransformOrigin();
|
||||
UpdateTransform();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,8 +381,8 @@ namespace MapControl
|
|||
{
|
||||
var p1 = MapTransform.Transform(southWest);
|
||||
var p2 = MapTransform.Transform(northEast);
|
||||
var lonScale = ActualWidth / (p2.X - p1.X) * 360d / TileSource.TileSize;
|
||||
var latScale = ActualHeight / (p2.Y - p1.Y) * 360d / TileSource.TileSize;
|
||||
var lonScale = RenderSize.Width / (p2.X - p1.X) * 360d / TileSource.TileSize;
|
||||
var latScale = RenderSize.Height / (p2.Y - p1.Y) * 360d / TileSource.TileSize;
|
||||
var lonZoom = Math.Log(lonScale, 2d);
|
||||
var latZoom = Math.Log(latScale, 2d);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@
|
|||
<Reference Include="System.Core">
|
||||
<HintPath>$(TargetFrameworkDirectory)System.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AnimationEx.Silverlight.cs" />
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ namespace MapControl
|
|||
}
|
||||
|
||||
var geometry = (PathGeometry)path.Data;
|
||||
var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(0d, 0d, ParentMap.RenderSize.Width, ParentMap.RenderSize.Height));
|
||||
var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(new Point(), ParentMap.RenderSize));
|
||||
var start = ParentMap.MapTransform.Transform(new Point(bounds.X, bounds.Y));
|
||||
var end = ParentMap.MapTransform.Transform(new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height));
|
||||
var minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, ParentMap.ZoomLevel) * 256d);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace MapControl
|
|||
Children.Add(new MapImage { Opacity = 0d });
|
||||
|
||||
updateTimer.Interval = TileContainer.UpdateInterval;
|
||||
updateTimer.Tick += (o, e) => UpdateImage();
|
||||
updateTimer.Tick += (s, e) => UpdateImage();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -119,15 +119,15 @@ namespace MapControl
|
|||
{
|
||||
updateTimer.Stop();
|
||||
|
||||
if (ParentMap != null && ActualWidth > 0 && ActualHeight > 0)
|
||||
if (ParentMap != null && RenderSize.Width > 0 && RenderSize.Height > 0)
|
||||
{
|
||||
updateInProgress = true;
|
||||
|
||||
var relativeSize = Math.Max(RelativeImageSize, 1d);
|
||||
var width = ActualWidth * relativeSize;
|
||||
var height = ActualHeight * relativeSize;
|
||||
var dx = (ActualWidth - width) / 2d;
|
||||
var dy = (ActualHeight - height) / 2d;
|
||||
var width = RenderSize.Width * relativeSize;
|
||||
var height = RenderSize.Height * relativeSize;
|
||||
var dx = (RenderSize.Width - width) / 2d;
|
||||
var dy = (RenderSize.Height - height) / 2d;
|
||||
|
||||
var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy));
|
||||
var loc2 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy));
|
||||
|
|
|
|||
|
|
@ -27,5 +27,10 @@ namespace MapControl
|
|||
{
|
||||
return new MapItem();
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item)
|
||||
{
|
||||
return item is MapItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ namespace MapControl
|
|||
return new MapItem();
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item)
|
||||
{
|
||||
return item is MapItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Geometry that selects all items inside its fill area, i.e.
|
||||
/// where Geometry.FillContains returns true for the item's viewport position.
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public static void AddParentMapHandlers(FrameworkElement element)
|
||||
{
|
||||
element.Loaded += (o, e) => GetParentMap(element);
|
||||
element.Unloaded += (o, e) => element.ClearValue(ParentMapProperty);
|
||||
element.Loaded += (s, e) => GetParentMap(element);
|
||||
element.Unloaded += (s, e) => element.ClearValue(ParentMapProperty);
|
||||
}
|
||||
|
||||
public static MapBase GetParentMap(UIElement element)
|
||||
|
|
|
|||
|
|
@ -89,12 +89,15 @@ namespace MapControl
|
|||
{
|
||||
var location = GetLocation(element);
|
||||
|
||||
ArrangeElement(element, finalSize, location != null);
|
||||
|
||||
if (location != null)
|
||||
{
|
||||
ArrangeElementWithLocation(element);
|
||||
SetViewportPosition(element, parentMap, location);
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrangeElementWithoutLocation(element, finalSize);
|
||||
}
|
||||
}
|
||||
|
||||
return finalSize;
|
||||
|
|
@ -138,9 +141,14 @@ namespace MapControl
|
|||
var parentMap = mapElement != null ? mapElement.ParentMap : GetParentMap(element);
|
||||
var location = e.NewValue as Location;
|
||||
|
||||
if ((location != null) != (e.OldValue != null))
|
||||
if (location == null)
|
||||
{
|
||||
ArrangeElement(element, null, location != null);
|
||||
ArrangeElementWithoutLocation(element, Size.Empty);
|
||||
}
|
||||
else if (e.OldValue == null)
|
||||
{
|
||||
// Arrange element once when Location was null before
|
||||
ArrangeElementWithLocation(element);
|
||||
}
|
||||
|
||||
SetViewportPosition(element, parentMap, location);
|
||||
|
|
@ -153,7 +161,7 @@ namespace MapControl
|
|||
|
||||
if (parentMap != null && location != null)
|
||||
{
|
||||
// keep viewport position near map center
|
||||
// Keep ViewportPosition near map center
|
||||
var mapPosition = parentMap.MapTransform.Transform(location, parentMap.Center.Longitude);
|
||||
viewportPosition = parentMap.ViewportTransform.Transform(mapPosition);
|
||||
element.SetValue(ViewportPositionProperty, viewportPosition);
|
||||
|
|
@ -194,87 +202,92 @@ namespace MapControl
|
|||
translateTransform.Y = viewportPosition.Y;
|
||||
}
|
||||
|
||||
private static void ArrangeElement(UIElement element, Size? panelSize, bool hasLocation)
|
||||
private static void ArrangeElementWithLocation(UIElement element)
|
||||
{
|
||||
var rect = new Rect(0d, 0d, element.DesiredSize.Width, element.DesiredSize.Height);
|
||||
var frameworkElement = element as FrameworkElement;
|
||||
|
||||
if (frameworkElement != null)
|
||||
{
|
||||
if (hasLocation)
|
||||
switch (frameworkElement.HorizontalAlignment)
|
||||
{
|
||||
switch (frameworkElement.HorizontalAlignment)
|
||||
{
|
||||
case HorizontalAlignment.Center:
|
||||
rect.X = -rect.Width / 2d;
|
||||
break;
|
||||
case HorizontalAlignment.Center:
|
||||
rect.X = -rect.Width / 2d;
|
||||
break;
|
||||
|
||||
case HorizontalAlignment.Right:
|
||||
rect.X = -rect.Width;
|
||||
break;
|
||||
case HorizontalAlignment.Right:
|
||||
rect.X = -rect.Width;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (frameworkElement.VerticalAlignment)
|
||||
{
|
||||
case VerticalAlignment.Center:
|
||||
rect.Y = -rect.Height / 2d;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Bottom:
|
||||
rect.Y = -rect.Height;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (frameworkElement.HorizontalAlignment != HorizontalAlignment.Left ||
|
||||
frameworkElement.VerticalAlignment != VerticalAlignment.Top)
|
||||
|
||||
switch (frameworkElement.VerticalAlignment)
|
||||
{
|
||||
if (!panelSize.HasValue)
|
||||
{
|
||||
var panel = frameworkElement.Parent as Panel;
|
||||
panelSize = panel != null ? panel.RenderSize : new Size();
|
||||
}
|
||||
case VerticalAlignment.Center:
|
||||
rect.Y = -rect.Height / 2d;
|
||||
break;
|
||||
|
||||
switch (frameworkElement.HorizontalAlignment)
|
||||
{
|
||||
case HorizontalAlignment.Center:
|
||||
rect.X = (panelSize.Value.Width - rect.Width) / 2d;
|
||||
break;
|
||||
case VerticalAlignment.Bottom:
|
||||
rect.Y = -rect.Height;
|
||||
break;
|
||||
|
||||
case HorizontalAlignment.Right:
|
||||
rect.X = panelSize.Value.Width - rect.Width;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case HorizontalAlignment.Stretch:
|
||||
rect.Width = panelSize.Value.Width;
|
||||
break;
|
||||
element.Arrange(rect);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
private static void ArrangeElementWithoutLocation(UIElement element, Size parentSize)
|
||||
{
|
||||
var rect = new Rect(0d, 0d, element.DesiredSize.Width, element.DesiredSize.Height);
|
||||
var frameworkElement = element as FrameworkElement;
|
||||
|
||||
switch (frameworkElement.VerticalAlignment)
|
||||
{
|
||||
case VerticalAlignment.Center:
|
||||
rect.Y = (panelSize.Value.Height - rect.Height) / 2d;
|
||||
break;
|
||||
if (frameworkElement != null)
|
||||
{
|
||||
if (parentSize.IsEmpty)
|
||||
{
|
||||
var parent = frameworkElement.Parent as UIElement;
|
||||
parentSize = parent != null ? parent.RenderSize : new Size();
|
||||
}
|
||||
|
||||
case VerticalAlignment.Bottom:
|
||||
rect.Y = panelSize.Value.Height - rect.Height;
|
||||
break;
|
||||
switch (frameworkElement.HorizontalAlignment)
|
||||
{
|
||||
case HorizontalAlignment.Center:
|
||||
rect.X = (parentSize.Width - rect.Width) / 2d;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Stretch:
|
||||
rect.Height = panelSize.Value.Height;
|
||||
break;
|
||||
case HorizontalAlignment.Right:
|
||||
rect.X = parentSize.Width - rect.Width;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case HorizontalAlignment.Stretch:
|
||||
rect.Width = parentSize.Width;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (frameworkElement.VerticalAlignment)
|
||||
{
|
||||
case VerticalAlignment.Center:
|
||||
rect.Y = (parentSize.Height - rect.Height) / 2d;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Bottom:
|
||||
rect.Y = parentSize.Height - rect.Height;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Stretch:
|
||||
rect.Height = parentSize.Height;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ using System.Runtime.InteropServices;
|
|||
using System.Windows;
|
||||
|
||||
#if SILVERLIGHT
|
||||
[assembly: AssemblyTitle("Silverlight Map Control")]
|
||||
[assembly: AssemblyTitle("XAML Map Control (Silverlight)")]
|
||||
[assembly: AssemblyDescription("XAML Map Control Library for Silverlight")]
|
||||
#else
|
||||
[assembly: AssemblyTitle("WPF Map Control")]
|
||||
[assembly: AssemblyTitle("XAML Map Control (WPF)")]
|
||||
[assembly: AssemblyDescription("XAML Map Control Library for WPF")]
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
||||
#endif
|
||||
|
|
@ -15,8 +15,8 @@ using System.Windows;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -66,7 +66,9 @@ namespace MapControl
|
|||
|
||||
internal void BeginGetTiles(TileLayer tileLayer, IEnumerable<Tile> tiles)
|
||||
{
|
||||
if (tiles.Any())
|
||||
var tileList = tiles.ToList();
|
||||
|
||||
if (tileList.Count > 0)
|
||||
{
|
||||
// get current TileLayer property values in UI thread
|
||||
var dispatcher = tileLayer.Dispatcher;
|
||||
|
|
@ -76,7 +78,7 @@ namespace MapControl
|
|||
var animateOpacity = tileLayer.AnimateTileOpacity;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
GetTiles(tiles.ToList(), dispatcher, tileSource, sourceName, maxDownloads, animateOpacity));
|
||||
GetTiles(tileList, dispatcher, tileSource, sourceName, maxDownloads, animateOpacity));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,14 +19,15 @@ namespace MapControl
|
|||
RenderTransform = transform;
|
||||
}
|
||||
|
||||
protected Panel TileContainer
|
||||
private Panel TileContainer
|
||||
{
|
||||
get { return Parent as Panel; }
|
||||
}
|
||||
|
||||
protected void RenderTiles()
|
||||
private void RenderTiles()
|
||||
{
|
||||
Children.Clear();
|
||||
|
||||
foreach (var tile in tiles)
|
||||
{
|
||||
Children.Add(tile.Image);
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ namespace MapControl
|
|||
|
||||
public Brush Background { get; set; }
|
||||
|
||||
protected ContainerVisual TileContainer
|
||||
private ContainerVisual TileContainer
|
||||
{
|
||||
get { return Parent as ContainerVisual; }
|
||||
}
|
||||
|
||||
protected void RenderTiles()
|
||||
private void RenderTiles()
|
||||
{
|
||||
using (var drawingContext = RenderOpen())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ namespace MapControl
|
|||
|
||||
private readonly MatrixTransform transform = new MatrixTransform();
|
||||
private readonly TileImageLoader tileImageLoader = new TileImageLoader();
|
||||
private List<Tile> tiles = new List<Tile>();
|
||||
private string description = string.Empty;
|
||||
private TileSource tileSource;
|
||||
private List<Tile> tiles = new List<Tile>();
|
||||
private Int32Rect grid;
|
||||
private int zoomLevel;
|
||||
|
||||
|
|
@ -59,7 +60,6 @@ namespace MapControl
|
|||
partial void Initialize();
|
||||
|
||||
public string SourceName { get; set; }
|
||||
public TileSource TileSource { get; set; }
|
||||
public int MinZoomLevel { get; set; }
|
||||
public int MaxZoomLevel { get; set; }
|
||||
public int MaxParallelDownloads { get; set; }
|
||||
|
|
@ -73,10 +73,36 @@ namespace MapControl
|
|||
set { description = value.Replace("{y}", DateTime.Now.Year.ToString()); }
|
||||
}
|
||||
|
||||
public TileSource TileSource
|
||||
{
|
||||
get { return tileSource; }
|
||||
set
|
||||
{
|
||||
tileSource = value;
|
||||
|
||||
if (grid.Width > 0 && grid.Height > 0)
|
||||
{
|
||||
tileImageLoader.CancelGetTiles();
|
||||
tiles.Clear();
|
||||
|
||||
if (tileSource != null)
|
||||
{
|
||||
SelectTiles();
|
||||
RenderTiles();
|
||||
tileImageLoader.BeginGetTiles(this, tiles.Where(t => !t.HasImageSource));
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderTiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TileSourceUriFormat
|
||||
{
|
||||
get { return TileSource != null ? TileSource.UriFormat : string.Empty; }
|
||||
set { TileSource = new TileSource(value); }
|
||||
get { return tileSource != null ? tileSource.UriFormat : string.Empty; }
|
||||
set { TileSource = !string.IsNullOrWhiteSpace(value) ? new TileSource(value) : null; }
|
||||
}
|
||||
|
||||
internal void SetTransformMatrix(Matrix transformMatrix)
|
||||
|
|
@ -84,14 +110,14 @@ namespace MapControl
|
|||
transform.Matrix = transformMatrix;
|
||||
}
|
||||
|
||||
protected internal virtual void UpdateTiles(int zoomLevel, Int32Rect grid)
|
||||
internal void UpdateTiles(int zoomLevel, Int32Rect grid)
|
||||
{
|
||||
this.grid = grid;
|
||||
this.zoomLevel = zoomLevel;
|
||||
|
||||
tileImageLoader.CancelGetTiles();
|
||||
|
||||
if (TileSource != null)
|
||||
if (tileSource != null)
|
||||
{
|
||||
SelectTiles();
|
||||
RenderTiles();
|
||||
|
|
@ -99,14 +125,14 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
protected internal virtual void ClearTiles()
|
||||
internal void ClearTiles()
|
||||
{
|
||||
tileImageLoader.CancelGetTiles();
|
||||
tiles.Clear();
|
||||
RenderTiles();
|
||||
}
|
||||
|
||||
protected void SelectTiles()
|
||||
private void SelectTiles()
|
||||
{
|
||||
var maxZoomLevel = Math.Min(zoomLevel, MaxZoomLevel);
|
||||
var minZoomLevel = maxZoomLevel;
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||
<TargetPlatformIdentifier>Windows</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>8.1</TargetPlatformVersion>
|
||||
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
|
||||
<TargetFrameworkVersion />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("WinRT Map Control")]
|
||||
[assembly: AssemblyTitle("XAML Map Control (WinRT)")]
|
||||
[assembly: AssemblyDescription("XAML Map Control Library for Windows Runtime")]
|
||||
|
||||
[assembly: AssemblyProduct("XAML Map Control")]
|
||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ namespace ViewModel
|
|||
Interval = TimeSpan.FromSeconds(0.1)
|
||||
};
|
||||
|
||||
timer.Tick += (sender, e) =>
|
||||
timer.Tick += (s, e) =>
|
||||
{
|
||||
var p = Points.Last();
|
||||
p.Location = new Location(p.Location.Latitude + 0.001, p.Location.Longitude + 0.002);
|
||||
|
|
@ -181,7 +181,7 @@ namespace ViewModel
|
|||
if (p.Location.Latitude > 54d)
|
||||
{
|
||||
p.Name = "Stopped";
|
||||
((DispatcherTimer)sender).Stop();
|
||||
((DispatcherTimer)s).Stop();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@
|
|||
</Style>
|
||||
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
|
|
@ -84,7 +82,6 @@
|
|||
</Style>
|
||||
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
|
@ -157,7 +154,7 @@
|
|||
<Slider Width="100" Minimum="0" Maximum="1"
|
||||
Value="{Binding Opacity, ElementName=mapImage, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
<CheckBox Margin="5" VerticalAlignment="Bottom" Content="Seamarks" Click="SeamarksClick"/>
|
||||
<CheckBox Margin="5" VerticalAlignment="Bottom" Content="Seamarks" Checked="SeamarksChecked" Unchecked="SeamarksUnchecked"/>
|
||||
<ComboBox x:Name="tileLayerComboBox" Margin="5" VerticalAlignment="Bottom" Width="120" SelectionChanged="TileLayerSelectionChanged">
|
||||
<sys:String>OpenStreetMap</sys:String>
|
||||
<sys:String>OpenCycleMap</sys:String>
|
||||
|
|
|
|||
|
|
@ -39,20 +39,14 @@ namespace SilverlightApplication
|
|||
map.TileLayer = tileLayers[(string)comboBox.SelectedItem];
|
||||
}
|
||||
|
||||
private void SeamarksClick(object sender, RoutedEventArgs e)
|
||||
private void SeamarksChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var checkBox = (CheckBox)sender;
|
||||
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
||||
var tileLayer = tileLayers["Seamarks"];
|
||||
map.TileLayers.Add((TileLayer)((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
|
||||
}
|
||||
|
||||
if ((bool)checkBox.IsChecked)
|
||||
{
|
||||
map.TileLayers.Add(tileLayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.TileLayers.Remove(tileLayer);
|
||||
}
|
||||
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TileLayers.Remove((TileLayer)((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@
|
|||
<HintPath>$(TargetFrameworkDirectory)System.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Windows.Browser" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@
|
|||
</Style>
|
||||
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="local:BindingHelper.LocationPath" Value="Location"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
|
@ -104,7 +102,6 @@
|
|||
</Style>
|
||||
<Style x:Key="PushpinItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="local:BindingHelper.LocationPath" Value="Location"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Setter Property="Template">
|
||||
|
|
@ -182,7 +179,7 @@
|
|||
<TextBlock Text="Image Opacity" HorizontalAlignment="Center" Foreground="Gray" FontSize="14"/>
|
||||
<Slider Margin="10,-10,10,-10" Width="200" Value="50" ValueChanged="ImageOpacitySliderValueChanged"/>
|
||||
</StackPanel>
|
||||
<CheckBox Margin="10" VerticalAlignment="Center" Content="Seamarks" Click="SeamarksClick"/>
|
||||
<CheckBox Margin="10" VerticalAlignment="Center" Content="Seamarks" Checked="SeamarksChecked" Unchecked="SeamarksUnchecked"/>
|
||||
<ComboBox x:Name="tileLayerComboBox" Margin="10" Width="200" VerticalAlignment="Center" SelectionChanged="TileLayerSelectionChanged">
|
||||
<ComboBoxItem>OpenStreetMap</ComboBoxItem>
|
||||
<ComboBoxItem>OpenCycleMap</ComboBoxItem>
|
||||
|
|
|
|||
|
|
@ -21,27 +21,21 @@ namespace StoreApplication
|
|||
}
|
||||
}
|
||||
|
||||
private void SeamarksClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var checkBox = (CheckBox)sender;
|
||||
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
||||
var tileLayer = tileLayers["Seamarks"];
|
||||
|
||||
if ((bool)checkBox.IsChecked)
|
||||
{
|
||||
map.TileLayers.Add(tileLayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.TileLayers.Remove(tileLayer);
|
||||
}
|
||||
}
|
||||
|
||||
private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var comboBox = (ComboBox)sender;
|
||||
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
||||
map.TileLayer = tileLayers[(string)((ComboBoxItem)comboBox.SelectedItem).Content];
|
||||
}
|
||||
|
||||
private void SeamarksChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TileLayers.Add((TileLayer)((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
|
||||
}
|
||||
|
||||
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TileLayers.Remove((TileLayer)((TileLayerCollection)Resources["TileLayers"])["Seamarks"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@
|
|||
</Style>
|
||||
<Style x:Key="PointItemStyle" TargetType="map:MapItem">
|
||||
<Setter Property="map:MapPanel.Location" Value="{Binding Location}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="map:MapItem">
|
||||
|
|
@ -124,7 +122,6 @@
|
|||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
|
@ -224,7 +221,8 @@
|
|||
<Slider ToolTip="Image Opacity" Width="100" VerticalAlignment="Center"
|
||||
Minimum="0" Maximum="1" Value="{Binding Opacity, ElementName=mapImage}"/>
|
||||
</StackPanel>
|
||||
<CheckBox ToolTip="Seamarks Overlay" Margin="7" VerticalAlignment="Bottom" Content="Seamarks" Click="SeamarksClick"/>
|
||||
<CheckBox ToolTip="Seamarks Overlay" Margin="7" VerticalAlignment="Bottom" Content="Seamarks"
|
||||
Checked="SeamarksChecked" Unchecked="SeamarksUnchecked"/>
|
||||
<ComboBox ToolTip="Tile Layer" Margin="5" VerticalAlignment="Bottom" DisplayMemberPath="SourceName"
|
||||
SelectedIndex="0" ItemsSource="{Binding Source={StaticResource TileLayersViewSource}}"/>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -78,19 +78,14 @@ namespace WpfApplication
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void SeamarksClick(object sender, RoutedEventArgs e)
|
||||
private void SeamarksChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var seamarks = (TileLayer)Resources["SeamarksTileLayer"];
|
||||
var checkBox = (CheckBox)sender;
|
||||
map.TileLayers.Add((TileLayer)Resources["SeamarksTileLayer"]);
|
||||
}
|
||||
|
||||
if ((bool)checkBox.IsChecked)
|
||||
{
|
||||
map.TileLayers.Add(seamarks);
|
||||
}
|
||||
else
|
||||
{
|
||||
map.TileLayers.Remove(seamarks);
|
||||
}
|
||||
private void SeamarksUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
map.TileLayers.Remove((TileLayer)Resources["SeamarksTileLayer"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyVersion("1.12.0")]
|
||||
[assembly: AssemblyFileVersion("1.12.0")]
|
||||
[assembly: AssemblyVersion("1.12.1")]
|
||||
[assembly: AssemblyFileVersion("1.12.1")]
|
||||
[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.34003
|
||||
// Runtime Version:4.0.30319.34014
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
|
|
|||
Loading…
Reference in a new issue