Offline Maps using Esri.ArcGISRuntime.Tasks.Offline Namespace for ios,cannot add data to GeoDatabase

2869
1
04-12-2016 01:45 AM
AkshataKhandeparkar
New Contributor

I have written the following code to generate an offline database for Esri maps,

var documents = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
                var seedFile = documents + @"\EsriMap.geodatabase";
                if (!File.Exists (seedFile)) {
                    File.Create (seedFile);
                }

The database file is created at the specified location, But when I try to access it,

var localGdb = await Geodatabase.OpenAsync (seedFile);

the following exception is thrown "No Data"

When I try to add data to the geodatabase,(generate the database)

var geoDB =

new GeodatabaseSyncTask (new Uri (mapUrl));

await geoDB.FeatureServiceInfo.LoadAsync ();
if (geoDB.FeatureServiceInfo.LoadStatus == LoadStatus.Loaded)

{
  var geoDBParams = await geoDB.CreateDefaultGenerateGeodatabaseParametersAsync ();
  var geoDatabase = geoDB.GenerateGeodatabase (geoDBParams, seedFile);

}

It throws and exception,"ArcGIS Runtime error Invalid access range Feature service is not loaded, it needs to be loaded before passed into the sync task" at

' await geoDB.CreateDefaultGenerateGeodatabaseParametersAsync ();'


                   

Tags (1)
0 Kudos
1 Reply
Nicholas-Furness
Esri Regular Contributor

Hi,

A .geodatabase file must come either from an online feature service (from ArcGIS Online or from ArcGIS Server 10) or side-loaded from ArcGIS for Desktop's Create Runtime Content tool. Even an "empty" .geodatabase file (one that contains no data) must have a schema with a well defined set of tables already created, so you don't create an offline .geodatabase by hand.

For more information and to understand the various workflows, I highly recommend checking out these two videos from the 2015 Developer Summit. Part I and Part II of Building Offline Apps with the ArcGIS Runtime SDK.

For documentation, see "Allow offline editing" here to learn how to enable support for sync in an ArcGIS Online Feature Service and see here for creating a .geodatabase file to side-load onto your device.

You can see if your Feature Service has Sync enabled by looking at the REST endpoint. A sync-enabled feature service will have 3 specific REST endpoints listed at the bottom of the service's HTML page: "Create Replica", "Synchronize Replica" and "Unregister Replica".

https://gis.nexgenam.com/ArcGIS/rest/services/SLP/MapServer does not have these listed and so is not enabled for sync. Note, also, it needs to be a Feature Service, not a Map Service. Your ArcGIS Server Admin might be able to publish a matching Feature Service with Sync Enabled for you for the above service if that's what you want.

Lastly, your code does not look like iOS code. Did you mean to post this in the .Net space? Regardless, all the above remains true.

Hope this helps,

Nick.