public static GenerateOfflineMap Instance {get;}
Public Shared ReadOnly Property Instance As GenerateOfflineMap
public static GenerateOfflineMap Instance {get;}
Public Shared ReadOnly Property Instance As GenerateOfflineMap
{
var hasSyncEnabledContent = GenerateOfflineMap.Instance.GetCanGenerateReplicas(map);
if (hasSyncEnabledContent)
{
//TODO - use status...
}
}
{
//namespace ArcGIS.Desktop.Mapping.Offline
var extent = mapView.Extent;
await QueuedTask.Run(() =>
{
//Check map has sync-enabled content that can be taken offline
var hasSyncEnabledContent = GenerateOfflineMap.Instance.GetCanGenerateReplicas(map);
if (hasSyncEnabledContent)
{
//Generate Replicas and take the content offline
//sync-enabled content gets copied local into a SQLite DB
var gen_params = new GenerateReplicaParams()
{
Extent = extent, //SR of extent must match map SR
//DestinationFolder can be left blank, if specified,
//it must exist. Defaults to project offline maps location
DestinationFolder = @"C:\Data\Offline"
};
//Sync-enabled layer content will be resourced to point to the
//local replica content.
GenerateOfflineMap.Instance.GenerateReplicas(map, gen_params);
}
});
}
{
//Check map has local syncable content
var canSyncContent = await QueuedTask.Run(() =>
GenerateOfflineMap.Instance.GetCanSynchronizeReplicas(map));
if (canSyncContent)
{
//TODO - use status
}
}
{
await QueuedTask.Run(() =>
{
//Check map has local syncable content
var canSyncContent = GenerateOfflineMap.Instance.GetCanSynchronizeReplicas(map);
if (canSyncContent)
{
//Sync Replicas - changes since last sync are pushed to the
//parent replica. Parent changes are pulled to the client.
//Unsaved edits are _not_ sync'd.
GenerateOfflineMap.Instance.SynchronizeReplicas(map);
}
});
}
{
await QueuedTask.Run(() =>
{
//Check map has local syncable content
//Either..
//var canSyncContent = GenerateOfflineMap.Instance.GetCanSynchronizeReplicas(map);
//Or...both accomplish the same thing...
var canRemove = GenerateOfflineMap.Instance.GetCanRemoveReplicas(map);
if (canRemove)
{
//Remove Replicas - any unsync'd changes are lost
//Call sync _first_ to push any outstanding changes if
//needed. Local syncable content is re-sourced
//to point to the service
GenerateOfflineMap.Instance.RemoveReplicas(map);
}
});
}
{
//Does the map have any exportable raster content?
var canExport = GenerateOfflineMap.Instance.GetCanExportRasterTileCache(map);
var rasterTileExtent = MapView.Active.Extent;
if (canExport)
{
//Check the available LOD scale ranges
var scales = GenerateOfflineMap.Instance.GetExportRasterTileCacheScales(map, rasterTileExtent);
//Pick the desired LOD scale
var max_scale = scales[scales.Count() / 2];
//Configure the export parameters
var export_params = new ExportTileCacheParams()
{
Extent = rasterTileExtent,//Use same extent as was used to retrieve scales
MaximumUserDefinedScale = max_scale
//DestinationFolder = .... (optional)
};
//If DestinationFolder is not set, output defaults to project
//offline maps location set in the project properties. If that is
//not set, output defaults to the current project folder location.
//Do the export. Depending on the MaximumUserDefinedScale and the
//area of the extent requested, this can take minutes for tile packages
//over 1 GB or less if your network speed is slow...
GenerateOfflineMap.Instance.ExportRasterTileCache(map, export_params);
}
}
{
var mapVectorTileExtent = MapView.Active.Extent;
//Does the map have any exportable vector tile content?
var canExport = GenerateOfflineMap.Instance.GetCanExportVectorTileCache(map);
if (canExport)
{
//Check the available LOD scale ranges
var scales = GenerateOfflineMap.Instance.GetExportVectorTileCacheScales(map, mapVectorTileExtent);
//Pick the desired LOD scale
var max_scale = scales[scales.Count() / 2];
//Configure the export parameters
var export_params = new ExportTileCacheParams()
{
Extent = mapVectorTileExtent,//Use same extent as was used to retrieve scales
MaximumUserDefinedScale = max_scale,
DestinationFolder = @"C:\Data\Offline"
};
//If DestinationFolder is not set, output defaults to project
//offline maps location set in the project properties. If that is
//not set, output defaults to the current project folder location.
//Do the export. Depending on the MaximumUserDefinedScale and the
//area of the extent requested, this can take minutes for tile packages
//over 1 GB or less if your network speed is slow...
GenerateOfflineMap.Instance.ExportVectorTileCache(map, export_params);
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)