0

I am playing with MapControl in UWP, and I would like to forbid the looping in the horizontal scrolling with a left mouse click, I would like my widget be like map not like a globe and map rotating with a right click, I have looked in Internet and cannot find any hint.

horizontal_scrolling

rotating_issue

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
Andrey Mazur
  • 510
  • 4
  • 14

2 Answers2

0

You can use the CenterChanged and ZoomChanged events of the MapControl to observe the map position changes.

In the handler for these events you can then use the GetLocationFromOffset method to retrieve the location of the corners of the current view and Center to retrieve the current center location and if you the view left your "boundary", you can just force the map back using TrySetViewBoundsAsync method.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
0

You can disable the rotation capability of the map by setting the RotateInteractionMode property - see:

https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.maps.mapinteractionmode

You may also want to disable TiltInteractionMode.

Disabling panning wraparound behavior is harder - there is no direct support for this. You can listen to the view changed or changing events as suggested above and then force the view back, but it will be tricky to pick the right bounds to prevent wrapping but still allow normal navigation, and you'll also probably see some view jittering when you hit this condition.

Duncan Lawler
  • 1,772
  • 8
  • 13