mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Reworked MapProjection
Return nullable Point from LocationToMap. Use MapRect instead of WinUI/UWP Rect replacement. Drop Vector. Add Scale struct.
This commit is contained in:
parent
bab1788334
commit
218a85316c
28 changed files with 249 additions and 324 deletions
|
|
@ -65,7 +65,7 @@ namespace MapControl
|
|||
private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
|
||||
{
|
||||
TransformMap(e.ManipulationOrigin,
|
||||
e.DeltaManipulation.Translation,
|
||||
(Point)e.DeltaManipulation.Translation,
|
||||
e.DeltaManipulation.Rotation,
|
||||
e.DeltaManipulation.Scale.LengthSquared / 2d);
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ namespace MapControl
|
|||
var translation = position - mousePosition.Value;
|
||||
mousePosition = position;
|
||||
|
||||
TranslateMap(translation);
|
||||
TranslateMap((Point)translation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace MapControl
|
|||
{
|
||||
IEnumerable<Location> Locations { get; }
|
||||
|
||||
Drawing GetDrawing(IList<Point> positions, double scale, double rotation);
|
||||
Drawing GetDrawing(IList<Point> points, double scale, double rotation);
|
||||
}
|
||||
|
||||
public class MapItemsImageLayer : MapImageLayer
|
||||
|
|
@ -47,23 +47,27 @@ namespace MapControl
|
|||
{
|
||||
var scale = ParentMap.ViewTransform.Scale;
|
||||
var rotation = ParentMap.ViewTransform.Rotation;
|
||||
var mapRect = projection.BoundingBoxToRect(boundingBox);
|
||||
var mapRect = projection.BoundingBoxToMapRect(boundingBox);
|
||||
var drawings = new DrawingGroup();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var positions = item.Locations.Select(l => projection.LocationToMap(l)).ToList();
|
||||
var points = item.Locations
|
||||
.Select(location => projection.LocationToMap(location))
|
||||
.Where(point => point.HasValue)
|
||||
.Select(point => point.Value)
|
||||
.ToList();
|
||||
|
||||
if (positions.Any(p => mapRect.Contains(p)))
|
||||
if (points.Any(point => mapRect.Contains(point)))
|
||||
{
|
||||
for (int i = 0; i < positions.Count; i++)
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
positions[i] = new Point(
|
||||
scale * (positions[i].X - mapRect.X),
|
||||
scale * (mapRect.Height + mapRect.Y - positions[i].Y));
|
||||
points[i] = new Point(
|
||||
scale * (points[i].X - mapRect.X),
|
||||
scale * (mapRect.Height + mapRect.Y - points[i].Y));
|
||||
}
|
||||
|
||||
drawings.Children.Add(item.GetDrawing(positions, scale, rotation));
|
||||
drawings.Children.Add(item.GetDrawing(points, scale, rotation));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,11 @@ namespace MapControl
|
|||
{
|
||||
if (locations.Count() >= 2)
|
||||
{
|
||||
var points = locations.Select(location => LocationToView(location, longitudeOffset));
|
||||
var points = locations
|
||||
.Select(location => LocationToView(location, longitudeOffset))
|
||||
.Where(point => point.HasValue)
|
||||
.Select(point => point.Value);
|
||||
|
||||
var figure = new PathFigure
|
||||
{
|
||||
StartPoint = points.First(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue