AnsweredAssumed Answered

How do you limit the map extent in ArcGIS Runtime .NET 100.2

Question asked by nathan.raley on Jan 12, 2018
Latest reply on Oct 14, 2019 by nathan.raley

How can you set the maximum extent for the MapView in the .NET runtime version 100.2?


I've tried intercepting the OnViewPointChanged, but my viewpoint doesn't exactly match the bounds that I had set, I am assuming due to the zoom level scaling or something of that nature?


So then I tried on my setup, 


            // Set the current viewpoint/extent of the map and animate to it            await SetViewpointGeometryAsync(MapBounds).ContinueWith((prevTask) =>            {                 _viewPointBounds = GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;                 _prevBounds = _viewPointBounds;             });

and on my event handler:


private void OnViewPointChanged(object sender, EventArgs e) {     var newBounds = GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;       if (!GeometryEngine.Within(newBounds, _viewPointBounds))         SetViewpoint(new Viewpoint(_prevBounds));     else        _prevBounds = newBounds; }

This works great for the first time I load the map, but when I set up the map for another view, it ends up stuck at the old one, despite my _viewPointBounds and _prevBounds being reset via the code above in the setup that is called again.


Any ideas?  I feel like I am pretty close, but I'm just missing something.