I'm working on an iOS app which gets its feature services from an instance of ArcGIS Enterprise.
I'm trying to add the ability to generate an offline map on-demand as described in this article. Currently, the user selects a region of the basemap using a rectangle or polygon and their selection is passed into an OfflineMapTask to generate the parameters, but the completion returns the following error:
"Error Domain=com.esri.arcgis.runtime.error Code=6 "Illegal state" UserInfo={NSLocalizedFailureReason=The online map must have an item property which is its online portal item."
Here is my function. The error branch is always taken, so I edited out the rest of the function to save space.
func <SPAN class="token function">takeMapOffline</SPAN><SPAN class="punctuation token">(</SPAN>areaOfInterest<SPAN class="operator token">:</SPAN> AGSGeometry<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//1. Declare offline map task</SPAN>
let offlineMapTask <SPAN class="operator token">=</SPAN> <SPAN class="token function">AGSOfflineMapTask</SPAN><SPAN class="punctuation token">(</SPAN>onlineMap<SPAN class="operator token">:</SPAN> self<SPAN class="punctuation token">.</SPAN>mapView<SPAN class="punctuation token">.</SPAN>map<SPAN class="operator token">!</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">//2. Define parameters</SPAN>
offlineMapTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">defaultGenerateOfflineMapParameters</SPAN><SPAN class="punctuation token">(</SPAN>withAreaOfInterest<SPAN class="operator token">:</SPAN> areaOfInterest<SPAN class="punctuation token">,</SPAN> completion<SPAN class="operator token">:</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="punctuation token">(</SPAN>parameters<SPAN class="punctuation token">,</SPAN> error<SPAN class="punctuation token">)</SPAN> in
<SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"@@@ Generate parameters 1: Start"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> let error <SPAN class="operator token">=</SPAN> error <SPAN class="punctuation token">{</SPAN>
<SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"@@@ Generate parameters 2: Error, getting parameters failed"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="token function">print</SPAN><SPAN class="punctuation token">(</SPAN>error<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="comment token">//The success branch here never executes</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Can someone explain what this error means and how I can fix it?