mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Added Surface sample application
This commit is contained in:
parent
e77e3d8562
commit
6b25260536
27 changed files with 564 additions and 45 deletions
|
|
@ -3,7 +3,6 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
|
@ -395,7 +394,7 @@ namespace MapControl
|
|||
{
|
||||
SetTransformOrigin(origin);
|
||||
updateTransform = false;
|
||||
Heading += rotation;
|
||||
Heading = (((Heading + rotation) % 360d) + 360d) % 360d;
|
||||
ZoomLevel += Math.Log(scale, 2d);
|
||||
updateTransform = true;
|
||||
UpdateViewTransform();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ using System.Windows.Shapes;
|
|||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws a graticule overlay. The minimum spacing in pixels between adjacent graticule lines
|
||||
/// is specified by the MinSpacingPixels property.
|
||||
/// Draws a graticule overlay. The minimum spacing in pixels between adjacent
|
||||
/// graticule lines is specified by the MinLineSpacing property.
|
||||
/// </summary>
|
||||
public class MapGraticule : MapElement
|
||||
{
|
||||
|
|
@ -41,8 +41,8 @@ namespace MapControl
|
|||
public static readonly DependencyProperty StrokeThicknessProperty = Shape.StrokeThicknessProperty.AddOwner(
|
||||
typeof(MapGraticule), new FrameworkPropertyMetadata(0.5, (o, e) => ((MapGraticule)o).pen.Thickness = (double)e.NewValue));
|
||||
|
||||
public static readonly DependencyProperty MinSpacingPixelsProperty = DependencyProperty.Register(
|
||||
"MinSpacingPixels", typeof(double), typeof(MapGraticule), new FrameworkPropertyMetadata(100d));
|
||||
public static readonly DependencyProperty MinLineSpacingProperty = DependencyProperty.Register(
|
||||
"MinLineSpacing", typeof(double), typeof(MapGraticule), new FrameworkPropertyMetadata(100d));
|
||||
|
||||
public static double[] Spacings =
|
||||
new double[] { 1d / 60d, 1d / 30d, 1d / 12d, 1d / 6d, 1d / 4d, 1d / 3d, 1d / 2d, 1d, 2d, 5d, 10d, 15d, 20d, 30d, 45d };
|
||||
|
|
@ -106,10 +106,13 @@ namespace MapControl
|
|||
set { SetValue(StrokeThicknessProperty, value); }
|
||||
}
|
||||
|
||||
public double MinSpacingPixels
|
||||
/// <summary>
|
||||
/// Minimum spacing in pixels between adjacent graticule lines.
|
||||
/// </summary>
|
||||
public double MinLineSpacing
|
||||
{
|
||||
get { return (double)GetValue(MinSpacingPixelsProperty); }
|
||||
set { SetValue(MinSpacingPixelsProperty, value); }
|
||||
get { return (double)GetValue(MinLineSpacingProperty); }
|
||||
set { SetValue(MinLineSpacingProperty, value); }
|
||||
}
|
||||
|
||||
protected override int VisualChildrenCount
|
||||
|
|
@ -127,7 +130,7 @@ namespace MapControl
|
|||
Rect bounds = parentMap.ViewportTransform.Inverse.TransformBounds(new Rect(parentMap.RenderSize));
|
||||
Location loc1 = parentMap.MapTransform.TransformBack(bounds.TopLeft);
|
||||
Location loc2 = parentMap.MapTransform.TransformBack(bounds.BottomRight);
|
||||
double minSpacing = MinSpacingPixels * 360d / (Math.Pow(2d, parentMap.ZoomLevel) * 256d);
|
||||
double minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, parentMap.ZoomLevel) * 256d);
|
||||
double spacing = Spacings[Spacings.Length - 1];
|
||||
|
||||
if (spacing >= minSpacing)
|
||||
|
|
|
|||
|
|
@ -82,12 +82,12 @@ namespace MapControl
|
|||
this.tileLayer = tileLayer;
|
||||
}
|
||||
|
||||
internal void StartDownloadTiles(ICollection<Tile> tiles)
|
||||
internal void BeginDownloadTiles(ICollection<Tile> tiles)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(StartDownloadTilesAsync, new List<Tile>(tiles.Where(t => t.Image == null && t.Uri == null)));
|
||||
ThreadPool.QueueUserWorkItem(BeginDownloadTilesAsync, new List<Tile>(tiles.Where(t => t.Image == null && t.Uri == null)));
|
||||
}
|
||||
|
||||
internal void StopDownloadTiles()
|
||||
internal void CancelDownloadTiles()
|
||||
{
|
||||
lock (pendingTiles)
|
||||
{
|
||||
|
|
@ -103,7 +103,7 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
private void StartDownloadTilesAsync(object newTilesList)
|
||||
private void BeginDownloadTilesAsync(object newTilesList)
|
||||
{
|
||||
List<Tile> newTiles = (List<Tile>)newTilesList;
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ namespace MapControl
|
|||
{
|
||||
TraceInformation("{0} - {1}", tile.Uri, ((HttpWebResponse)exc.Response).StatusCode);
|
||||
}
|
||||
else if (exc.Status == WebExceptionStatus.RequestCanceled)
|
||||
else if (exc.Status == WebExceptionStatus.RequestCanceled) // by HttpWebRequest.Abort in CancelDownloadTiles
|
||||
{
|
||||
TraceInformation("{0} - {1}", tile.Uri, exc.Status);
|
||||
}
|
||||
|
|
@ -283,7 +283,7 @@ namespace MapControl
|
|||
|
||||
private static void TraceInformation(string format, params object[] args)
|
||||
{
|
||||
Trace.TraceInformation("[{0:00}] {1}", Thread.CurrentThread.ManagedThreadId, string.Format(format, args));
|
||||
//Trace.TraceInformation("[{0:00}] {1}", Thread.CurrentThread.ManagedThreadId, string.Format(format, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,21 +58,21 @@ namespace MapControl
|
|||
this.grid = grid;
|
||||
this.zoomLevel = zoomLevel;
|
||||
|
||||
tileImageLoader.StopDownloadTiles();
|
||||
tileImageLoader.CancelDownloadTiles();
|
||||
|
||||
if (VisualParent != null && TileSource != null)
|
||||
{
|
||||
SelectTiles();
|
||||
RenderTiles();
|
||||
|
||||
tileImageLoader.StartDownloadTiles(tiles);
|
||||
tileImageLoader.BeginDownloadTiles(tiles);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearTiles()
|
||||
{
|
||||
tiles.Clear();
|
||||
tileImageLoader.StopDownloadTiles();
|
||||
tileImageLoader.CancelDownloadTiles();
|
||||
}
|
||||
|
||||
private void SelectTiles()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue