Set max envelope in 100 SDK for Android

2898
12
05-05-2017 07:31 AM
EmilLöfblom
New Contributor

In the "old" SDK for iOS and probably also for Android you're able to set a max envelop on the map view to define a panning area for the map.

How do I do that in the 100 SDK for Android? Can't find any method like that in the MapView class.

0 Kudos
12 Replies
AlexanderNohe1
Occasional Contributor III

I could not find this either in the current SDK.

I would encourage you to log an enhancement request with your local esri distributor asking for the setMaxExtent() method to be brought back to the MapView class.  This will give you a public tracking number which can then be used to check on the status of the enhancement.

0 Kudos
EmilLöfblom
New Contributor

The equivalent in the Android 10.x SDK seem to be setMaxExtent(), MapView | ArcGIS Android 10.2.9 API 

Anyone have any suggestions how to implement such logic your self until this method is added to the 100 SDK?

0 Kudos
AlexanderNohe1
Occasional Contributor III

Hi Emil Löfblom‌,

This is more of a hack until it is ready, but what you could do is implement a GeoView| arcgis-android  addViewpointChangedListener(ViewpointChangedListener listener) and when the viewpoint changes, check the extent of the mapView.  If the extent is outside what you want, then add setViewpointGeometryAsync(Geometry boundingGeometry) MapView| arcgis-android  to zoom back to the extent you want.  It won't stop people from panning outside the map extent, but when they do, they will automatically be panned back to the extent you wish to keep them in.

 

Thanks,

Alexander

0 Kudos
EmilLöfblom
New Contributor

Thanks for the suggestion. That is actually what we have in place now, but it's not very pretty.

About logging an enhancement at my local ESRI distributor. Will it be sufficient to just create and idea in "ArcGIS Ideas"or is it better to contact the distributor, even though we don't have a support agreement in place?

0 Kudos
AlexanderNohe1
Occasional Contributor III

Logging an enhancement on the ideas site should be fine.

0 Kudos
CharlesLoftis
New Contributor III

Thanks for the workaround... being a newbie to arcgis's android API I'm struggling with getting this implemented.

Question 1:

  • How do I compare my mapview's envelope with those from the GeoView? 

I was able to add the viewpointChangedListener and get a reference to the geoView from via "viewpointChangedEvent.getSource()". I tried "(viewpointChangedEvent.getSource()).getTargetGeometry().getExtent()", but sometimes I get a null pointer exception on the target geometry object. 

Further, I'm not really sure how to get my MapView and/or ArcGisMap's full envelope. What I'm looking for is the full extents of my map, which is a relatively small geographic area (think smaller than a zip code). Note: my maps are being loaded locally from mobile map (mmpk) and/or tile package (tpk) for strict offline usage. For now I know what max/min lat lons border my map are so I can hardcode those extents, but I'm not even sure how to create an envelope from lat lons vs x/y. So my other questions:

  • How to I create my MapView's envelope from lat/lons vs x/y? or...
  • (not exactly sure of the proper terminology) how can I programmatically obtain my MapView's (and/or underlying ArcGisMap) full visual extents i.e., Not just what's shown onscreen, but the full width and height of the map loaded from the mobile map/tile package.
0 Kudos
by Anonymous User
Not applicable

I am also wondering how you even get the full extent of a mapview?  I do not want the currently visible extent, but the entire extent.  This does not seem easily obtainable.  Have been looking through the samples and don't see any evidence that there is a way to do it.  In the old SDK there was a very easy method (MapView.getExtent()).  

0 Kudos
AlexanderNohe1
Occasional Contributor III

Great news Emil Löfblom‌!  It looks as though there is an existing enhancement request logged with ESRI for this issue.  The defect is: ENH-000104889 - Add a method to set the maximum extent of the map to Android Runtime 100.0.

I hope this helps!

0 Kudos
by Anonymous User
Not applicable

I 100% agree that Max Extent is really important capability to have.  I still do not see this in 100.2.1.  Is there any possibility this will be in the upcoming 100.2.2??????

0 Kudos