How to download map without portal item

854
6
11-02-2020 09:06 AM
by Anonymous User
Not applicable

I am following this example: https://developers.arcgis.com/ios/latest/swift/sample-code/generate-offline-map/ for downloading a map to an iOS device as a mobile map package. Rather than using a portal item like this:

I want to use a regular map from a map view (my particular use case has the map being created in iOS, with the llayers added on programmatically. This means it would look like this:

The issue I am having is that the parameters in the offline map task are empty when using an online map, whereas they are populated when using a portal item:

I am not sure why this is, any help would be greatly appreciated.

0 Kudos
6 Replies
Nicholas-Furness
Esri Regular Contributor

Hi.

This is not something the offline map task supports. The offline map task is centered on a web map as the source:

The map must be a web map either on ArcGIS Online or an on-premises ArcGIS Portal.

To download what you've built in code, you can do one of two things:

  • Save the map you created in code as a web map, and create the offline map task from that.
  • Download the layers in the map you created in code on a service-by-service basis (so multiple layers from one service is a single GenerateGeodatabase job, each vector tile layer and image time layer is a separate export tile cache job). This is what the offline map task does behind the scenes. But you will need to manage the downloads, and resultant file storage. You will then have a set of local data that you'll need to use to create a map in code each time your app needs the map. As you can see, the offline map task is super helpful here.

If you don't need to keep the data offline, and just want to avoid recreating the map each time in code, you can serialize your AGSMap with toJSON and read it back in with fromJSON.

Hope that helps.

0 Kudos
by Anonymous User
Not applicable

Thanks for the reply Nicholas,

In regards to being able to save the map i created in code as a web map, how do I go about doing that? Is this something I can do in code, or would I have to use ArcGIS online to create the web map?

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Hi Mike.

You can use the saveAs method on AGSMap.

Note that since this involves writing content to ArcGIS Online, this requires a Basic level runtime license (see License your app—ArcGIS Runtime SDK for iOS | ArcGIS for Developers  for more info). If that's a non-starter, then you'll need to use ArcGIS Online to create the web map.

0 Kudos
by Anonymous User
Not applicable

I see. The app is currently registered with the Lite license unfortunately. With a Learn ArcGIS account, would I be able to write content to ArcGIS Online, or is it only the Basic runtime license that will unlock this feature?

0 Kudos
Nicholas-Furness
Esri Regular Contributor

I'm not really sure what the Learn account is. Is it this? If your login through the Learn account gives you Editor, Field Worker, Creator, or a GIS Professional type, that'll be enough to get you a Basic license when you log in and license the Runtime as described here.

But if you are just doing some R&D and developing (rather than deploying an app into production) then you can just not license the app at all and it'll run in development mode. This will display a watermark on any map view, but you can try out all the Runtime APIs.

Does that help?

0 Kudos
Banksy98
New Contributor

Yes, that link you included is what the LearnArcGIS account is. I saw my User Type and it does say 'Creator', so it sounds like I should be able to do this. I will take a look at that example you linked. Will update this thread once I see the result.

0 Kudos