MapView.MaximumExtent .NET help

2198
8
10-10-2016 01:41 AM
Highlighted
New Contributor III

Hi guys,

I'm attempting to set the .MaximumExtent property in MapView.cs as I assume it restricts the user to the provided envelope (not 100% sure as the documentation is a tad light). However, when I add this property in the xaml or code behind it literally does nothing, it has no affect whatsoever on how I can navigate the map! Is there something I'm missing? Or am I misunderstanding the purpose of the property.

Thanks,

Aaron

8 Replies
Highlighted
New Contributor II

Using current SDK 10.2.7 Zoom In/Out and vertical limitation works for me, but the map panning seems not limited horizontally.

Using SDK Quartz Beta I cannot find MapView.MaximumExtent nor something adequate (in MapView class).

Waiting for the SDK commercial release I try to return Viewpoint after NavigationCompleted event.

Reply
0 Kudos
Highlighted
Frequent Contributor

If you want to constrain map at a given extent, you can subscribe to ViewpointChanged and check whether the current viewpoint is still within the maximum extent you want to set it to.

var extent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry)?.TargetGeometry?.Extent; //current extent

You can use GeometryEngine.Equals(extent, _lastCheckedExtent) and GeometryEngine.Within(extent, MaximumExtent) to ignore ones that you've already checked or fall within set maximum.

Otherwise, MyMapView.SetViewpoint(new Viewpoint(MaximumExtent)) to set viewpoint to desired extent.

Highlighted
New Contributor II

Hi Jennifer,

I implemented your suggestion and it works well except when the map has inertia after releasing the mouse in which case the map violently bounces back and forth when it hits the boundary of the extent. The size of the bounce increases as the map is thrown faster. The shudder lasts about two seconds. Is there any way to stop this from happening? Here is the code I put in the ViewpointChanged event. I simply save the last extent that was within the MaxExtent and set the Viewpoint to that extent when the map moves outside of it. 

Envelope extent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry)?.TargetGeometry?.Extent;
if (GeometryEngine.Within(extent, MaxExtent))
{
      _LastExtent = extent;
}
else
{
      Viewpoint vp = new Viewpoint(_LastExtent);
      MyMapView.SetViewpoint(vp);
}

Reply
0 Kudos
Highlighted
Frequent Contributor

Hi Richard,

I'm able to reproduce the issue. Calling `MyMapView.CancelSetViewpointOperations();` before SetViewpoint also does not seem to cancel animation. I have logged an issue.

Meanwhile, this worked for me but I am not sure if it's an option for your app... workaround is to disable flick.

MyMapView.InteractionOptions = new MapViewInteractionOptions() { IsFlickEnabled = false };

Thank you for your feedback.

Jennifer

Highlighted
New Contributor II

Thanks for the quick response Jennifer!

I found that solution about an hour ago. I toggle it off when the extent is outside the max extent and then toggle it back on when the navigation completes.  It works perfectly. 

Reply
0 Kudos
Highlighted
New Contributor II

The big problem comes when the map is rotated, I have spent two days figuring out how to limit the rotated viewpoint to nonrotated maximumextent to satisfy the GeometryEngine.Within() but I am still unlucky.

Esri should definitelly implement this functionality!

Thanks!

Reply
0 Kudos
Highlighted
New Contributor II

Hi,

It seems to me that for the horizontal limitation (with 10.2.x Runtime) it is necessary to disable the "WrapAround" property of the MapView...

Regards,

damien.

PS: I also am looking for the equivalent of MaximumExtent with version 100.x of SDK .NET.

Reply
0 Kudos
Highlighted
Occasional Contributor

I'm also trying to limit the max extent of my map.  Is there anyway to make this work in 100.3?   If I try the approach recommended above the call to GetCurrentViewpoint does not return the extent that the map is trying to zoom/pan to. Because setting/changing the viewpoint happened asyncronously it appears to return the extent values before the map has finished setting the originally requested extent.

Reply
0 Kudos