Skip to content

Commit 1cbd4f0

Browse files
jfversluisCopilot
andcommitted
Address MoveToRegion review feedback
- Reduce code duplication: MoveToRegion(MapSpan) now delegates to MoveToRegion(MapSpan, bool) with animated=true - Add antimeridian crossing unit test to verify MapSpan.FromLocations correctly handles points near ±180° longitude Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c76b7c1 commit 1cbd4f0

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/Controls/Maps/src/Map.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,7 @@ public IEnumerator<IMapPin> GetEnumerator()
259259
/// </summary>
260260
/// <param name="mapSpan">A <see cref="MapSpan"/> object containing details on what region should be shown.</param>
261261
/// <exception cref="ArgumentNullException">Thrown when <paramref name="mapSpan"/> is <see langword="null"/>.</exception>
262-
public void MoveToRegion(MapSpan mapSpan)
263-
{
264-
if (mapSpan is null)
265-
{
266-
throw new ArgumentNullException(nameof(mapSpan));
267-
}
268-
269-
_lastMoveToRegion = mapSpan;
270-
Handler?.Invoke(nameof(IMap.MoveToRegion), new MoveToRegionRequest(_lastMoveToRegion, true));
271-
}
262+
public void MoveToRegion(MapSpan mapSpan) => MoveToRegion(mapSpan, true);
272263

273264
/// <summary>
274265
/// Adjusts the viewport of the map control to view the specified region, with control over animation.

src/Controls/tests/Core.UnitTests/MapTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,5 +1066,21 @@ public void IMap_LastUserLocation_ReturnsMapLastUserLocation()
10661066
}
10671067

10681068
#endregion
1069+
1070+
[Fact]
1071+
public void FromLocationsHandlesAntimeridianCrossing()
1072+
{
1073+
// Points near the antimeridian (179° and -179° should result in a small span, not 358°)
1074+
var locations = new[]
1075+
{
1076+
new Location(0, 179),
1077+
new Location(0, -179)
1078+
};
1079+
1080+
var span = MapSpan.FromLocations(locations);
1081+
1082+
// The span should be small (around 2-3 degrees), not 358 degrees
1083+
Assert.True(span.LongitudeDegrees < 10, $"Expected small longitude span for antimeridian crossing, got {span.LongitudeDegrees}");
1084+
}
10691085
}
10701086
}

0 commit comments

Comments
 (0)