-
Notifications
You must be signed in to change notification settings - Fork 522
Offline Data
Nathan Castle edited this page Oct 27, 2017
·
2 revisions
Some samples require offline data to be downloaded from ArcGIS Online. The sample viewer and samples handle this automatically using the DataManager class. This class can be found for the following platforms:
The implementations are generally consistent across each platform, aside from platform-specific paths.
The data manager performs the following functions that you should be aware of if you implement your own app:
- Downloading the data by ID from ArcGIS Online
- Automatically extracting zip files as needed; some files downloaded from ArcGIS online will be in zip archives
For contributors interested in creating a new sample with offline data, note the following requirements:
- The data must be available on the ArcGIS Runtime's ArcGIS Online organization. If you need content that is not available, contact an Esri team member.
- The sample's metadata.json file must be updated with the item IDs in the
DataItemIds
property and the names of the used files in theDataFileNames
property. The order of the IDs and names should match. - Data access code should follow the pattern of using a function to get the path of the offline data file on disk. All code in that function should be wrapped in a
#region offlinedata
tag. See example below:
// Get the file path for the style dictionary
private async Task<string> GetStyleDictionaryPath()
{
#region offlinedata
// The data manager provides a method to get the folder
string folder = DataManager.GetDataFolder();
// Get the full path
string filepath = Path.Combine(folder, "SampleData", "FeatureLayerDictionaryRenderer", "mil2525d.stylx");
// Check if the file exists
if (!File.Exists(filepath))
{
// Download the file
await DataManager.GetData("e34835bf5ec5430da7cf16bb8c0b075c", "FeatureLayerDictionaryRenderer");
}
return filepath;
#endregion offlinedata
}
Note that in the above code snippet, "FeatureLayerDictionaryRenderer" is the name of the sample. Be sure to replace this with the name of the sample you're implementing to avoid conflicts with files from other samples.