mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Version 5.0: Separated map projection and view transform.
This commit is contained in:
parent
53723844a0
commit
c7cb2efcdb
47 changed files with 401 additions and 382 deletions
|
|
@ -53,13 +53,6 @@ namespace MapControl
|
|||
BackgroundProperty.OverrideMetadata(typeof(MapBase), new FrameworkPropertyMetadata(Brushes.Transparent));
|
||||
}
|
||||
|
||||
public MapBase()
|
||||
{
|
||||
MapProjection = new WebMercatorProjection();
|
||||
ScaleRotateTransform.Children.Add(ScaleTransform);
|
||||
ScaleRotateTransform.Children.Add(RotateTransform);
|
||||
}
|
||||
|
||||
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
|
||||
{
|
||||
base.OnRenderSizeChanged(sizeInfo);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<AssemblyOriginatorKeyFile>..\..\MapControl.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Product>XAML Map Control</Product>
|
||||
<Version>4.17.0</Version>
|
||||
<Version>5.0.0</Version>
|
||||
<Description>XAML Map Control Library</Description>
|
||||
<Authors>Clemens Fischer</Authors>
|
||||
<Copyright>Copyright © 2020 Clemens Fischer</Copyright>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace MapControl
|
|||
|
||||
if (projection.IsNormalCylindrical)
|
||||
{
|
||||
DrawCylindricalGraticule(drawingContext, projection, lineDistance, labelFormat);
|
||||
DrawCylindricalGraticule(drawingContext, lineDistance, labelFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -54,9 +54,9 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawCylindricalGraticule(DrawingContext drawingContext, MapProjection projection, double lineDistance, string labelFormat)
|
||||
private void DrawCylindricalGraticule(DrawingContext drawingContext, double lineDistance, string labelFormat)
|
||||
{
|
||||
var boundingBox = projection.ViewportRectToBoundingBox(new Rect(ParentMap.RenderSize));
|
||||
var boundingBox = ParentMap.ViewportRectToBoundingBox(new Rect(ParentMap.RenderSize));
|
||||
var latLabelStart = Math.Ceiling(boundingBox.South / lineDistance) * lineDistance;
|
||||
var lonLabelStart = Math.Ceiling(boundingBox.West / lineDistance) * lineDistance;
|
||||
var latLabels = new List<Label>((int)((boundingBox.North - latLabelStart) / lineDistance) + 1);
|
||||
|
|
@ -72,8 +72,8 @@ namespace MapControl
|
|||
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground, pixelsPerDip)));
|
||||
|
||||
drawingContext.DrawLine(pen,
|
||||
projection.LocationToViewportPoint(new Location(lat, boundingBox.West)),
|
||||
projection.LocationToViewportPoint(new Location(lat, boundingBox.East)));
|
||||
ParentMap.LocationToViewportPoint(new Location(lat, boundingBox.West)),
|
||||
ParentMap.LocationToViewportPoint(new Location(lat, boundingBox.East)));
|
||||
}
|
||||
|
||||
for (var lon = lonLabelStart; lon <= boundingBox.East; lon += lineDistance)
|
||||
|
|
@ -83,15 +83,15 @@ namespace MapControl
|
|||
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeface, FontSize, Foreground, pixelsPerDip)));
|
||||
|
||||
drawingContext.DrawLine(pen,
|
||||
projection.LocationToViewportPoint(new Location(boundingBox.South, lon)),
|
||||
projection.LocationToViewportPoint(new Location(boundingBox.North, lon)));
|
||||
ParentMap.LocationToViewportPoint(new Location(boundingBox.South, lon)),
|
||||
ParentMap.LocationToViewportPoint(new Location(boundingBox.North, lon)));
|
||||
}
|
||||
|
||||
foreach (var latLabel in latLabels)
|
||||
{
|
||||
foreach (var lonLabel in lonLabels)
|
||||
{
|
||||
var position = projection.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
|
||||
var position = ParentMap.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
|
||||
|
||||
drawingContext.PushTransform(new RotateTransform(ParentMap.Heading, position.X, position.Y));
|
||||
drawingContext.DrawText(latLabel.Text,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue