How To Restrict Map Panning to an Area

4752
11
Jump to solution
05-21-2017 06:46 PM
ThomasSaldana
New Contributor II

Hello,

does anyone know to restrict map panning to an area?

Im trying to something similar to this:

https://www.mapbox.com/mapbox-gl-js/example/restrict-bounds/ 

But in my ArcGIS android application. I want to restrict my basemap, so that only my campus is displayed and not the whole world.

Thank you in advance!

0 Kudos
1 Solution

Accepted Solutions
MirHashmi
Occasional Contributor

Hi,

The following snippet of code can be used to apply a custom extent on one's basemap. In your case, it would be the extents of your campus.

Envelope myExtents = new Envelope(xmin,ymin,xmax,ymax);
myExtents = (Envelope) GeometryEngine.project(myExtents, SpatialReference.create(102100), mMapView.getSpatialReference());
mMapView.setMaxExtent(myExtents);
mMapView.setExtent(myExtents);

Thanks.

View solution in original post

11 Replies
MirHashmi
Occasional Contributor

Hi,

The following snippet of code can be used to apply a custom extent on one's basemap. In your case, it would be the extents of your campus.

Envelope myExtents = new Envelope(xmin,ymin,xmax,ymax);
myExtents = (Envelope) GeometryEngine.project(myExtents, SpatialReference.create(102100), mMapView.getSpatialReference());
mMapView.setMaxExtent(myExtents);
mMapView.setExtent(myExtents);

Thanks.

ThomasSaldana
New Contributor II

Thank you. And one final question. Do you know how i would be able to find the extents of my campus in ArcMap? 

0 Kudos
MirHashmi
Occasional Contributor

Hi Thomas,

There are quite a few ways to get extents of a feature. One of them is as follows:

1. Select your campus feature and zoom to it.

2. From the top menu click on “View” and select “Data Frame Properties”.

3. Click on the Tab “Data Frame” and from the drop down under “Extents” select “Fixed Extent”.

4. This will show up the current extents of the current view with your selected feature.

Top = YMax, Bottom = YMin, Left = XMin, Right = XMax

Thanks

ThomasSaldana
New Contributor II

Thank you!

0 Kudos
AlexanderNohe1
Occasional Contributor III

Hey Thomas,

Would you kindly mark the correct answer for this question so it highlights the answer for other users who may be running into similar problems.

Thanks,

Alexander

AlexanderNohe1
Occasional Contributor III

If you do not have an ArcMap license, you can use this tool called extent-helper:

JS Extent Helper 

This should help you generate an extent in the web mercator projection.

Hope this helps!

AlexanderNohe1
Occasional Contributor III

Which runtime are you trying to use?

In the latest runtime, this is yet to be exposed.  There is an enhancement request placed for this to be added to the new runtime:

ENH-000104889 Add a method to set the maximum extent of the map to Android Runtime 100.0

Alternatively, if you are working with the 10.2.x version of the runtime, mirhashmi2014‌'s answer would be correct.

AndreaChua
New Contributor

How can we achieve the camera bounds restriction on runtime sdk 100.1.0?

I have tried using similar method:

val bounds  =  Envelope(103.6, 1.161724, 104.09, 1.478184, SpatialReference.create(4326))
mViewMap.setViewPoint(ViewPoint(bounds))

*the above is in koltin

But it didn't have any effect on restricting the camera

I have loaded my map tiles using WmtsService

0 Kudos
AlexanderNohe1
Occasional Contributor III

This is not yet implemented for runtime version 100.x

This enhancement request is currently open and our engineers are hard at work implementing it:

ENH-000104889 Add a method to set the maximum extent of the map to Android Runtime 100.0