"Locking" Map Extent to a particular area

895
6
07-09-2020 01:44 PM
AlexAverill
New Contributor

I have been creating a QML application in 100.8, and I have been trying to sort out a way to limit users to be locked to a specific area of a map so that they are unable to pan outside of that area. It would seem reasonable to be able to set an Envelope to define that but I am unable to find anything promising in the documentation, or in previous questions. Though it is extremely possible I am just missing something.

Any thoughts or directions that you could point me that would be greatly appreciated.

0 Kudos
6 Replies
JaredCaccamo
Esri Contributor

Hi Alex Averill‌,

Are you looking to do this in an offline or online scenario? 

Best Regards,

Jared

0 Kudos
AlexAverill
New Contributor

Hello Jared,

Offline would be preferable in this instance.

0 Kudos
JaredCaccamo
Esri Contributor

Are you looking to remove all map navigation from the user or only allow map navigation within the "Locked" extent?

-Jared

0 Kudos
AlexAverill
New Contributor

The goal would be to allow navigation inside the "locked" area

0 Kudos
JaredCaccamo
Esri Contributor

Hi Alex Averill,

Unfortunately there is no out of the box way to accomplish what you are looking to do. There are only two ways I can see you accomplishing this.

  1. One would be to intercept mouse drag/key events and to prevent panning manually once you've go beyond the extent of your dataset.
  2. The other way would be to connect to MapView.viewpointChanged and whenever the user strays outside of the "locked" box you could move them back inside the bounds like it is bouncing back. 

If you have support, you could also officially log an enhancement request with them to possibly include this behavior out of the box with a future release.

Best Regards,

Jared

0 Kudos
AlexAverill
New Contributor

Hi Jared,

Thanks for getting back to me, I had started down the viewpointChanged path and wanted to make sure that there wasn't a cleaner way.

Thanks,

Alex

0 Kudos