Read offline map on disk already downloaded

629
3
Jump to solution
10-05-2023 03:24 AM
Flavio
by
New Contributor II

Hi Esri Community!

In my app i'm still using the old ArcGis Runtime iOS SDK 100.15.3. For what I need to do is awesome and it works like a charm. I'm planning to update to latest version later on but for now, i would like to ask you all a problem that I'm facing right now and can't figure out any solution to this.

In my app, i'm talking to a AGSPortal that exposes me two AGSPortalItem, one is a 2D Map and another one is a 3D Scene. In the app then, i've created a page where you can switch between 2D and 3D freely with a simple button.

Now, i would like to give users the ability to download portions of the 2D map on demand (in case they want to go fully offline or they want to see the 2D map in an area not covered by radio signal).

To do this, i've created a page where users will see a red square on top of the map and, once they tap on the "download" button, the portion of the map inside that red square will be downloaded. To do this, i'm relying on the "generateOfflineMapJob" that works like a charm and i can see the downloaded map as soon as the process is completed.

Now comes the question: I'm downloading all these maps in a specific folder called "/offlineMaps/" ..and each map has its own folder that goes by the name of the timestamp of the moment i've downloaded the app. So the default URL will be "filepathinsidetheiPhone/offlineMaps/1696434236". Inside this folder i can see all files downloaded by the generateOfflineMapJob by Esri SDK.

What i would like to achieve is that, once the map is downloaded, if i close and re-open the app, i would like to give users the possibility to select one of these offlineMaps downloaded on the disk and open it without re-downloading. How can i do that? i can't find any guide for this at all 😞
Is this even possible?

Thanks a lot for the help and really looking forward to hearing from you all people!

Flavio.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

You need to create a AGSMobileMapPackage pointing at the folder you downloaded the offline map to. Load the AGSMobileMapPackage, then get the map from the maps collection.

You can see that covered here. Unfortunately the iOS SDK code snippet has been removed, but you can get the gist from the Swift SDK snippet.

https://developers.arcgis.com/documentation/mapping-apis-and-services/offline/offline-maps/working-w...

This doc is admittedly a little hard to find. We're working on revised and improved offline doc that should make this easier to discover.

View solution in original post

3 Replies
Flavio
by
New Contributor II

I don't know if it can helps, but i've watched youtube videos here:
- https://www.youtube.com/watch?v=VTD2omhGVdI
- https://www.youtube.com/watch?v=y_ulEOkENtQ

Read the documentation here:
- https://developers.arcgis.com/ios/offline-maps-scenes-and-data/tutorials/display-an-offline-map-on-d...

and checked examples in GitHub here:
- https://github.com/Esri/arcgis-runtime-samples-ios

But couldn't find anything that goes beyond the download and use map instantly right after has been downloaded 😞

0 Kudos
Nicholas-Furness
Esri Regular Contributor

You need to create a AGSMobileMapPackage pointing at the folder you downloaded the offline map to. Load the AGSMobileMapPackage, then get the map from the maps collection.

You can see that covered here. Unfortunately the iOS SDK code snippet has been removed, but you can get the gist from the Swift SDK snippet.

https://developers.arcgis.com/documentation/mapping-apis-and-services/offline/offline-maps/working-w...

This doc is admittedly a little hard to find. We're working on revised and improved offline doc that should make this easier to discover.

Flavio
by
New Contributor II

Hi Nicholas!

Thanks a lot, your input was right on spot!

in the past, I did notice that the folder had a package.info file describing itself as a MobileMapPackage and I tried to use this API has well but I forgot to add the .load { } action...so i  was preparing everything but never loading it 🙂

Thanks a lot again for the help and support, it is now working flawlessly.

0 Kudos