-
Notifications
You must be signed in to change notification settings - Fork 85
Working with Offline content
Sathya Prasad edited this page Oct 11, 2016
·
6 revisions
You will need to create a TPK file using ArcMap. This can have any number of layers and levels as you desire. Please be mindful of the size.
- Create a ArcGISLocalTiledLayer object and initialize the path to the packaged TPK.
Note that if you would like to include TPK with your app you cannot use local relative path here since on devices like iOS and Android the apps have access to only virtual file system. So we will have to copy the TPK internally once the app opens.
property string runtimePath: AppFramework.userHomeFolder.filePath("ArcGIS/AppStudio/Runtime")
property string dataPath: runtimePath + "/Data"
//generic function to copy file(data) into a folder
function copyLocalData(filename, path) {
//your local bundled data location. In this case its a folder called "Data" in your app.
var resourceFolder = AppFramework.fileFolder(app.folder.folder("Data").path);
AppFramework.userHomeFolder.makePath(path);
var outputLocation = path + "/" + filename
resourceFolder.copyFile(filename, outputLocation);
return outputLocation;
}
ArcGISLocalTiledLayer {
path: copyLocalData("myawesome.tpk", datapPath)
}
- Download TPK online and then use it
//coming soon
You will need to export .geodatabase file from ArcMap. This .geodatabase file can contain one or more layers and you can set scale dependency and labelling options before exporting.
- Create a Geodatabase object and provide the local .geodatabasefile. In this sample file is saved in a folder called "Data" and uses the same function as above to copy local data in the device.
Geodatabase {
id: gdb
path: copyLocalData("buildings.geodatabase")
}
- Create a feature layer and add it to map if needed else just initialize.
FeatureLayer {
id: layer1
featureTable: GeodatabaseFeatureTable {
geodatabase: gdb.valid ? gdb : null
//featureServiceLayerName: "BuildingInteriorSpace"
featureServiceLayerId: 1
}
//this will work if labels is turned on in the geodatabase layer before exporting
enableLabels: true
onStatusChanged: {
if(status == Enums.LayerStatusInitialized) {
console.log("Geodatabase Layer initialized!!");
//you can zoom map to the layer extent here if needed
console.log(JSON.stringify(layer1.extent.json));
}
}
}