Select to view content in your preferred language

GeoDatabase

244
0
08-15-2022 04:16 AM
Amitkhillan
Emerging Contributor

Hi Everyone,

I have query regarding the code snippet below. If we downloaded the data and loading from cache/directory 

of mobile can Geodatabse layers load over Map if there is no internet connection available on device.

Please post your suggestions:

 map = ArcGISMap(
Basemap.Type.IMAGERY_WITH_LABELS_VECTOR,
23.9898,67.09090,14)
// create path to local geodatabase
var anglePointGeoDataBase =
Geodatabase(externalCacheDir.toString() + "/" +id + "/" + "filename")
// create a new geodatabase from local path
var mGeodatabase = Geodatabase(anglePointGeoDataBase.toString())

// load the geodatabase
mGeodatabase.loadAsync()

// create feature layer from geodatabase and add to the map
mGeodatabase.addDoneLoadingListener(Runnable {
if (mGeodatabase.getLoadStatus() == LoadStatus.LOADED) {
// access the geodatabase's feature table Trailheads
val geodatabaseFeatureTable: GeodatabaseFeatureTable =
mGeodatabase.getGeodatabaseFeatureTable("Trailheads")
geodatabaseFeatureTable.loadAsync()
// create a layer from the geodatabase feature table and add to map
val featureLayer = FeatureLayer(geodatabaseFeatureTable)
featureLayer.addDoneLoadingListener {
if (featureLayer.loadStatus == LoadStatus.LOADED) {
// set viewpoint to the feature layer's extent
mapView.setViewpointAsync(Viewpoint(featureLayer.fullExtent))
} else {
Toast.makeText(
this@SurveyMapActivity,
"Feature Layer failed to load!",
Toast.LENGTH_LONG
)
.show()
Log.e("TAG", "Feature Layer failed to load!")
}
}
// add feature layer to the map
mapView.getMap().getOperationalLayers().add(featureLayer)
} else {
Toast.makeText(this@SurveyMapActivity, "Geodatabase failed to load!", Toast.LENGTH_LONG)
.show()
Log.e("TAG", "Geodatabase failed to load!")
}
})
0 Kudos
0 Replies