Skip To Content ArcGIS for Developers Sign In Dashboard

Update an offline map

Maps that contain feature layers store their feature data in .geodatabase files, within a mobile map package, when it is taken offline. This allows users to continue to work with features, display their location, and analyze their spatial and non-spatial attributes, even when connectivity is lost. The extent to which these features can be updated (by the user or from an online service) depends on how the mobile map package was created. The following table summarizes the types of feature updates that are supported for each of the different offline workflows.

Supported feature updates

ArcGIS Pro on-demandpreplanned

Add, edit and create features in the local mobile map package. See edit features.

No

Yes

Yes

Synchronize the features in the mobile map package with their online feature service. The online feature service must support synchronization. See sync offline edits.

No

Yes

Yes

Apply scheduled updates from the online feature service to the mobile map package. Feature layers updated in this way are read-only. See apply scheduled updates.

No

No

Yes

Add, edit and create features in the online feature layer. Connectivity must be present and authentication may be required. See edit features.

Yes

No

No

If the mobile map package was created with ArcGIS Pro then the features in the geodatabase can not be edited (read-only) and cannot be updated from the online service. You can only provide updates to the features by creating a brand new mobile map package, as described in Take a map offline - ArcGIS Pro.

If the mobile map package was created using the on-demand or preplanned workflows, and synchronization was enabled on the online feature service, the features can be edited and synchronized back with the online feature service when connectivity is restored. You can synchronize changes with a single geodatabase, or with all geodatabases in the map, as described in Sync offline edits..

If the mobile map package was created using the preplanned workflow, the map author can schedule regular updates (delta files) to be generated for the individual map areas. This is described in define updates. Whenever connectivity is restored, the app can check for these scheduled updates, download any delta files and update the map's geodatabases. You can only apply scheduled updates to read-only data. The process is described in the following section:

Apply scheduled updates

  1. Create the OfflineMapSyncTask from the online map used in the preplanned workflow.

    OfflineMapSyncTask offlineMapSyncTask = await OfflineMapSyncTask.CreateAsync(MyMapView.Map);

  2. Retrieve the task's OfflineMapUpdateCapabilities and check that it supports scheduled updates.

    // Get the update capabilities for the task.
    OfflineMapUpdateCapabilities updateCapabilities = offlineMapSyncTask.UpdateCapabilities;
    if (updateCapabilities.SupportsScheduledUpdatesForFeatures)
    {
        Console.WriteLine("Scheduled updates are supported.");
    }
    else if (updateCapabilities.SupportsSyncWithFeatureServices)
    {
        Console.WriteLine("Synchronization with feature services is supported.");
    }

  3. Determine whether there are any updates available by calling the task's checkForUpdatesWithCompletion method.
    • If the map supportsScheduledUpdatesForFeatures, you can examine the downloadAvailability on the OfflineMapUpdatesInfo object. If there are downloads available, you can check to see how large the download is by using the scheduledUpdatesDownloadSize. You can use this information to determine whether to download updates immediately—for example, based on available disk space or network availability.
    • If the map supportsSyncWithFeatureServices, you can examine the uploadAvailability to see whether the offline map has any edits to upload. If so, go to step 4. It is not possible to determine whether there are online changes to download without performing a full feature synchronization.
    // Are there any updates available?
    OfflineMapUpdatesInfo updateInfo = await offlineMapSyncTask.CheckForUpdatesAsync();
    if(updateInfo == null)
    {
        Console.WriteLine("There are no updates available.");
        return;
    }
    
    // Are there any downloads available?
    switch (updateInfo.DownloadAvailability)
    {
        case OfflineUpdateAvailability.Available:
            Console.WriteLine("Online edits are available for download.");
            Console.WriteLine(string.Format("Download size is {0} bytes.", updateInfo.ScheduledUpdatesDownloadSize));
            break;
        case OfflineUpdateAvailability.None:
            Console.WriteLine("No online edits are available for download.");
            break;
        case OfflineUpdateAvailability.Indeterminate:
            Console.WriteLine("Unable to determine if edits are available for download.");
            break;
    }
    
    // Are there uploads available?
    switch (updateInfo.UploadAvailability)
    {
        case OfflineUpdateAvailability.Available:
            Console.WriteLine("Local edits are available to upload.");
            break;
        case OfflineUpdateAvailability.None:
            Console.WriteLine("No local edits are available to upload.");
            break;
        case OfflineUpdateAvailability.Indeterminate:
            Console.WriteLine("Unable to determine if edits are available to upload.");
            break;
    }
  4. Obtain the default offline map sync parameters using the method. Override any of these parameters, as required. For example, if resources are limited, you may want to overwrite the sync direction to just Upload local edits to the online service.
  5. Create the offline map sync job, offlineMapSyncJob, using the offline map sync parameters and run it.
  6. Upon completion, check the OfflineMapSyncResult for any errors.
  7. If supportsScheduledUpdatesForFeatures, determine whether the mobile map file needs to be reopened by examining the mobileMapPackageReopenRequired property on the OfflineMapUpdatesInfo object. If so, close the offline map before reopening it.

    // Get the default parameters for the offline map sync task.
    OfflineMapSyncParameters syncParams = await offlineMapSyncTask.CreateDefaultOfflineMapSyncParametersAsync();
    // (Change individual parameter values as needed).
    
    // Create the offline map sync job with the parameters.
    OfflineMapSyncJob syncJob = offlineMapSyncTask.SyncOfflineMap(syncParams);
    
    // Handle the progress changed event to show the percent complete.
    syncJob.ProgressChanged += (s, e) => 
    {
        Console.WriteLine(string.Format("Offline sync job is {0}% complete.", syncJob.Progress));
    };
    
    // Handle the job changed event to react to job success or failure.
    syncJob.JobChanged += async(s, e) => 
    {
        if(syncJob.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
        {
            OfflineMapSyncResult syncResult = await syncJob.GetResultAsync();
            if (syncResult.HasErrors)
            {
                // Report errors.
                return;
            }
    
            if (syncResult.IsMobileMapPackageReopenRequired)
            {
                // Close and reopen the mobile map package.
            }
        }
        else if(syncJob.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
        {
            // Report errors.
        }
    };
    
    // Start the sync job.
    syncJob.Start();

Next

When you have finished working with the mobile map package, ensure that you release its maps, layers, and geodatabases before closing or terminating the application. See Finish using an offline map for more details.