Select to view content in your preferred language

How to take borders of map or layer from mmpk and determine if current viewpoint has crossed them?

329
1
02-03-2023 12:16 AM
NikAleks
New Contributor

Hi all,

Looking for advice how can we take the borders from the maps from the MobileMapPackage() and determine if the current Viewpoint has crossed them?

For example:

We have some offline ArcGISMap() and loaded MobileMapPackage(). loadAndAwaitSuccessLoad(), but those maps from MobileMapPackage are not added to the ArcGISMap() yet.

So when we move around the base map our Viewpoint visible area changes and when it has crossed the boundaries of some maps from MobileMapPackage() we add them to the ArcGISMap.basemap.baseLayers.add(), but when our Viewpoint leave the boundaries of some specific MobileMapPackage() we remove it from the ArcGISMap().

Any tips on what approach to take is appreciated.

1 Reply
Shubham_Sharma
Esri Contributor

You can get the "Envelope" of the mobile map package and use it to perform spacial operations on the map to see if the viewpoint has crossed borders:

// get the full extent of the map package
val mapPackageEnvelope = mapPackage.maps[0].basemap.baseLayers[0].fullExtent
// perform spacial operations to find if the viewpoint has crossed borders
val isViewpointInsideEnvelope = GeometryEngine.contains(
    mapView.getCurrentViewpoint(
        Viewpoint.Type.BOUNDING_GEOMETRY
    ).targetGeometry,
    mapPackageEnvelope
)

// or disable panning outside of the envelope by setting maxExtent
mapPackage.maps[0].apply {
    maxExtent = mapPackageEnvelope
}

 

Check out the Android ArcGIS Runtime sample Perform spatial operations for more on how to determine the right operation to use.