mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Improve MapProjection
This commit is contained in:
parent
d8c416d552
commit
45cda387e4
|
|
@ -20,15 +20,9 @@ namespace MapControl
|
|||
{
|
||||
var center = MapToLocation(mapRect.Center);
|
||||
|
||||
if (center == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var width = mapRect.Width / Wgs84MeterPerDegree;
|
||||
var height = mapRect.Height / Wgs84MeterPerDegree;
|
||||
|
||||
return new CenteredBoundingBox(center, width, height);
|
||||
return center != null
|
||||
? new CenteredBoundingBox(center, mapRect.Width / Wgs84MeterPerDegree, mapRect.Height / Wgs84MeterPerDegree)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public virtual MapRect BoundingBoxToMapRect(BoundingBox boundingBox)
|
||||
{
|
||||
MapRect mapRect = null;
|
||||
|
||||
if (!double.IsNaN(boundingBox.South) && !double.IsNaN(boundingBox.West) &&
|
||||
!double.IsNaN(boundingBox.North) && !double.IsNaN(boundingBox.East))
|
||||
{
|
||||
|
|
@ -80,7 +82,7 @@ namespace MapControl
|
|||
|
||||
if (p1.HasValue && p2.HasValue)
|
||||
{
|
||||
return new MapRect(p1.Value, p2.Value);
|
||||
mapRect = new MapRect(p1.Value, p2.Value);
|
||||
}
|
||||
}
|
||||
else if (boundingBox.Center != null)
|
||||
|
|
@ -94,11 +96,11 @@ namespace MapControl
|
|||
var x = center.Value.X - width / 2d;
|
||||
var y = center.Value.Y - height / 2d;
|
||||
|
||||
return new MapRect(x, y, x + width, y + height);
|
||||
mapRect = new MapRect(x, y, x + width, y + height);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return mapRect;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue