How to including tables not related to geometries offline

447
3
11-30-2021 01:05 AM
frankm
by
New Contributor III

Hi,

I am working with a service that has two feature tables that are not related to geometries (we use them for lookup) and I access the tables by name from the map layers, by matching on layerInfo.serviceLayerName.

Now this works just fine when online, but in offline-mode it seems these tables are not available and I can't seem to find it explained how to include them when taking the map offline. I assume they aren't included because they have no relationship with any geometry. I would rather not assign them to a dummy layer, if possible.

Is there a way of having them included with the offline data cleanly? I have been examining the parameter setup (defaultDownloadPreplannedOfflineMapParameters) for the AGSOfflineMapTask but still haven't found a way.

I see there are older posts referring to a LayerQuery but I am unsure on how to incorporate that on iOS, I'm using the 100.12 SDK btw.

0 Kudos
3 Replies
Nicholas-Furness
Esri Regular Contributor

Hi @frankm,

Preplanned offline maps are generated from the web map definition, so you would need to include the tables in the web map itself. Here's an example web map that includes a layer and a table.

You can add tables to your web map by using the Add Data option in the ArcGIS Online map viewer. For example, here's a link to a table that can be added that way: https://services.arcgis.com/OfH668nDRN7tbJh0/arcgis/rest/services/Service_with_table_test/FeatureSer...

Once the web map contains a table (and if that table belongs to a service that is offline enabled), it'll be packaged up with the rest of the preplanned map content.

However, when I say "table" above, I mean an actual table definition on the service, which is exposed in Runtime via AGSMap.tables. See this example service definition which lists both a layer and a table:

2021-11-30_11-10-52.png

From your description, it might be the case that rather than using an explicit table, you're using a layer and just not setting a geometry on the records you put in there. If you added that to the web map, as you say, that would get added as another layer, and not as a table, and you'd access it via AGSMap.operationalLayers.

If that's the case, you have two options:

  1. Republish those "geometry-less" layers as tables and include them in the web map.
  2. Download and sync those layers in parallel with your offline map using a separate AGSGeodatabaseSyncTask.

Option 2 would involve some custom logic in your app to download and sync the geodatabase alongside the Offline Map. I.e. you would have an AGSOfflineMapTask and an AGSGeodatabaseSyncTask (or, more accurately, an AGSDownloadPreplannedOfflineMapJob and AGSGenedateGeodatabaseJob) working alongside one-another. Once downloaded, you can access the tables from the AGSGeodatabase and use them as before. When you sync the offline map with the AGSOfflineMapSyncTask, you'd also sync the downloaded geodatabase. Note that if you download the AGSGeodatabase and add the feature tables to the offline AGSMap's tables collection, then the AGSOfflineMapSyncTask should include those tables in the sync. I say "should" because I haven't tested that to confirm.

That feels like a bit of a fragile solution given the alternative, and you'd have to accommodate for a few potential error cases. There are some other nuances to this too. Happy to discuss if this is the way you decide to go. But if at all possible, I'd recommend you go for option 1.

Note, if you were downloading on-demand offline maps rather than preplanned offline maps, then you could potentially use overrides to include the additional tables that aren't part of the source web map, but then you're foregoing the benefits of preplanned offline maps.

Hope that helps.

frankm
by
New Contributor III

Thanks for the detailed answer! I will have to spend some time looking into it and test. Thanks again. Will post an update 🙂

0 Kudos
frankm
by
New Contributor III

Hi, so the end of the story was that the portal admin created a layer covering the area in question and then referenced the tables to it. Apparently the tables were included in the offline data, but not their content, which  was somewhat surprising. It works, finally 🙂

0 Kudos