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.
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:
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.
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?
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.
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?
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?
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.