mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 16:05:50 +00:00
MapPanel, MapPath location coercion
This commit is contained in:
parent
fb81fff901
commit
27729bf06c
5 changed files with 57 additions and 46 deletions
|
|
@ -80,9 +80,20 @@ namespace MapControl
|
|||
{
|
||||
var longitudeOffset = 0d;
|
||||
|
||||
if (location != null && parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical)
|
||||
if (parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical && location != null)
|
||||
{
|
||||
longitudeOffset = parentMap.CoerceLongitude(location.Longitude) - location.Longitude;
|
||||
var position = parentMap.LocationToView(location);
|
||||
|
||||
if (position.HasValue && !parentMap.InsideViewport(position.Value))
|
||||
{
|
||||
var coercedLongitude = parentMap.CoerceLongitude(location.Longitude);
|
||||
var coercedPosition = parentMap.LocationToView(new Location(location.Latitude, coercedLongitude));
|
||||
|
||||
if (coercedPosition.HasValue && parentMap.InsideViewport(coercedPosition.Value))
|
||||
{
|
||||
longitudeOffset = coercedLongitude - location.Longitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return longitudeOffset;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue