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!
Solved! Go to Solution.
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.
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.
Thank you. And one final question. Do you know how i would be able to find the extents of my campus in ArcMap?
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
Thank you!
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
If you do not have an ArcMap license, you can use this tool called extent-helper:
This should help you generate an extent in the web mercator projection.
Hope this helps!
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.
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
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: