mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 22:46:58 +00:00
Removed MoveMap feature
This commit is contained in:
parent
4c669f4df0
commit
4b2771d27d
6 changed files with 86 additions and 116 deletions
|
|
@ -277,39 +277,11 @@ namespace MapControl
|
|||
viewCenter = new Point(ActualWidth / 2d, ActualHeight / 2d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the map by the difference of the specified position in view coordinates and a temporary
|
||||
/// transform origin point that has been set before by a call to SetTransformCenter. Map movement
|
||||
/// must be terminated by a call to EndMoveMap. MoveMap provides higher accuracy than TranslateMap.
|
||||
/// </summary>
|
||||
public void MoveMap(Point position)
|
||||
{
|
||||
if (transformCenter != null)
|
||||
{
|
||||
viewCenter = position;
|
||||
UpdateTransform();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Terminates map movement by the MoveMap method.
|
||||
/// </summary>
|
||||
public void EndMoveMap()
|
||||
{
|
||||
if (transformCenter != null)
|
||||
{
|
||||
ResetTransformCenter();
|
||||
UpdateTransform();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the Center property according to the specified translation in view coordinates.
|
||||
/// </summary>
|
||||
public void TranslateMap(Point translation)
|
||||
{
|
||||
EndMoveMap();
|
||||
|
||||
if (translation.X != 0d || translation.Y != 0d)
|
||||
{
|
||||
var center = ViewToLocation(new Point(viewCenter.X - translation.X, viewCenter.Y - translation.Y));
|
||||
|
|
@ -328,7 +300,11 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public void TransformMap(Point center, Point translation, double rotation, double scale)
|
||||
{
|
||||
if (rotation != 0d || scale != 1d)
|
||||
if (rotation == 0d && scale == 1d)
|
||||
{
|
||||
TranslateMap(translation);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTransformCenter(center);
|
||||
|
||||
|
|
@ -352,12 +328,6 @@ namespace MapControl
|
|||
|
||||
UpdateTransform(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// More accurate than SetTransformCenter.
|
||||
//
|
||||
TranslateMap(translation);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -234,6 +234,24 @@ namespace MapControl
|
|||
{
|
||||
var center = new Point(mapRect.X + mapRect.Width / 2d, mapRect.Y + mapRect.Height / 2d);
|
||||
var position = parentMap.ViewTransform.MapToView(center);
|
||||
|
||||
if (parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical &&
|
||||
!parentMap.InsideViewBounds(position))
|
||||
{
|
||||
var location = parentMap.MapProjection.MapToLocation(center);
|
||||
|
||||
if (location != null)
|
||||
{
|
||||
var coercedPosition = parentMap.LocationToView(
|
||||
new Location(location.Latitude, parentMap.CoerceLongitude(location.Longitude)));
|
||||
|
||||
if (coercedPosition.HasValue)
|
||||
{
|
||||
position = coercedPosition.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var width = mapRect.Width * parentMap.ViewTransform.Scale;
|
||||
var height = mapRect.Height * parentMap.ViewTransform.Scale;
|
||||
var x = position.X - width / 2d;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue