Set max envelope in 100 SDK for Android

2899
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
by Anonymous User
Not applicable

Well answered my own question above regarding getting current extent of a map view in 100.4.  Kind of convoluted and not well documented.  Hope this helps others...

Viewpoint vp = mMapView.getCurrentViewpoint(Viewpoint.Type.BOUNDING_GEOMETRY);
Geometry extent = vp.getTargetGeometry();
0 Kudos
EmilLöfblom
New Contributor

Any news on enhancement: ENH-000104889.

Do you have any timeline when it will be released?

0 Kudos
by Anonymous User
Not applicable

I too am hoping this makes it into the runtime.  In the meantime this hack as per Alex's suggestion is working pretty well...

mMapView.addViewpointChangedListener(viewpointChangedEvent -> {
   try {
      Viewpoint vp = mMapView.getCurrentViewpoint(Viewpoint.Type.BOUNDING_GEOMETRY);
      Geometry curExtent = vp.getTargetGeometry();
      if(curExtent!=null) {
         LinearUnit miles = new LinearUnit(LinearUnitId.MILES);
         Geometry expandedMapExtent = GeometryEngine.bufferGeodetic(curExtent, 0.5, miles, Double.NaN, GeodeticCurveType.GEODESIC);
         boolean intersectsGDB = GeometryEngine.intersects(expandedMapExtent, s1Map.getBasemap().getBaseLayers().get(0).getFullExtent());
         if (!intersectsGDB) {
            mMapView.setViewpointCenterAsync(s1Map.getBasemap().getBaseLayers().get(0).getFullExtent().getCenter());
            mMapView.setViewpointGeometryAsync(s1Map.getBasemap().getBaseLayers().get(0).getFullExtent());
         }
      }
   } catch (Exception e) {
      e.printStackTrace();
   }
});
0 Kudos