This sample demonstrates how to consume an Esri mobile geodatabase by using a FeatureLayer
and a GeodatabaseFeatureTable
.
- ArcGISVectorTiledLayer
- FeatureLayer
- Geodatabase
- GeodatabaseFeatureTable
The sample creates an instance of GeodatabaseFeatureTable
by supplying the path to the local mobile geodatabase. The FeatureLayer is then supplied with the GeodatabaseFeatureTable
and added to the Map. The mobile geodatabase can either be obtained through ArcMap, with the Create Runtime Content geoprocessing tool, or through a feature service with the GeodatabaseSyncTask
.
// create a new Geodatabase from local path
mGeodatabase = new Geodatabase(geoDbFile);
// load the geodatabase
mGeodatabase.loadAsync();
// add feature layer from geodatabase to the ArcGISMap
mGeodatabase.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
for (GeodatabaseFeatureTable geoDbTable : mGeodatabase.getGeodatabaseFeatureTables()){
mMapView.getMap().getOperationalLayers().add(new FeatureLayer(geoDbTable));
}
}
});
// set initial viewpoint once MapView has spatial reference
mMapView.addSpatialReferenceChangedListener(new SpatialReferenceChangedListener() {
@Override
public void spatialReferenceChanged(SpatialReferenceChangedEvent spatialReferenceChangedEvent) {
// set the initial viewpoint
Point initPnt = new Point(-13214155, 4040194, SpatialReference.create(3857));
mMapView.setViewpoint(new Viewpoint(initPnt, 35e4));
}
});
- Download the data from the table below.
- Extract the contents of the downloaded zip file to disk.
- Create an ArcGIS/samples/FLGdb folder on your device. You can use the Android Debug Bridge (adb) tool found in /platform-tools.
- Open up a command prompt and execute the
adb shell
command to start a remote shell on your target device. - Navigate to your sdcard directory, e.g.
cd /sdcard/
. - Create the ArcGIS/samples/FLGdb directory,
mkdir ArcGIS/samples/FLGdb
. - You should now have the following directory on your target device,
/sdcard/ArcGIS/samples/FLGdb
. We will copy the contents of the downloaded data into this directory. Note: Directory may be slightly different on your device. - Exit the shell with the,
exit
command. - While still in your command prompt, navigate to the folder where you extracted the contents of the data from step 1 and execute the following command:
adb push LosAngeles.vtpk /sdcard/ArcGIS/samples/FLGdb
adb push LA_Trails.geodatabase /sdcard/ArcGIS/samples/FLGdb
Link | Local Location |
---|---|
Los Angeles Vector Tile Package | <sdcard> /ArcGIS/samples/FLGdb/LosAngeles.vtpk |
Los Angeles Trailheads | <sdcard> /ArcGIS/samples/FLGdb/LA_Trails.geodatabase |