<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why getPreplannedMapAreasAsync returns empty List? in Java Maps SDK Questions</title>
    <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192719#M2597</link>
    <description>&lt;P&gt;A quick answer as it's a Sunday... &amp;nbsp;there is a working sample app on &lt;A href="https://github.com/Esri/arcgis-runtime-samples-java/tree/main/map/download-preplanned-map" target="_self"&gt;gitHub&lt;/A&gt;&amp;nbsp;could take a look at. &amp;nbsp;It does pretty much the same as you are trying to do.&lt;/P&gt;&lt;P&gt;If that doesn't help then let me know and I'll take a closer look at your code on Monday.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
    <pubDate>Sun, 17 Jul 2022 10:37:38 GMT</pubDate>
    <dc:creator>MarkBaird</dc:creator>
    <dc:date>2022-07-17T10:37:38Z</dc:date>
    <item>
      <title>Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192718#M2596</link>
      <description>&lt;P&gt;Hello Everybody,&lt;/P&gt;&lt;P&gt;i'am struggeling arround with Preplanned offline Maps and need some help.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;offlinemaptask.getPreplannedMapAreasAsync returns a Empty UnmodifiableList.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What i have Done before:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I have created a new Map in the Arcgis Gallery (I tried OSM and Street as Basemaps) and&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Added a Offline Map Rectangle to the Map&lt;/LI&gt;&lt;LI&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShawnKleese_0-1658052622043.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45992i37625E56491BAAB7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShawnKleese_0-1658052622043.png" alt="ShawnKleese_0-1658052622043.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;LI&gt;Added the Permission to the API Key to use this Item&lt;/LI&gt;&lt;LI&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShawnKleese_1-1658052721829.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/45993i107AE204D06F3998/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShawnKleese_1-1658052721829.png" alt="ShawnKleese_1-1658052721829.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Environment/License:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I used the Free Developer Tier. I Have also in the same app the MapView and it worked - So Credentials and API Key is Ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code Snippet:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;ArcGISRuntimeEnvironment.setInstallDirectory(arcgisInstallFolder);
ArcGISRuntimeEnvironment.setApiKey(arcgisApiKey);
AuthenticationManager.setAuthenticationChallengeHandler(new DefaultAuthenticationChallengeHandler());

Credential cred = new UserCredential("username", "password");
portal = new Portal("https://www.arcgis.com/");
portal.setCredential(cred);
portalItem = new PortalItem(portal, "2098a0d8b#Cleaned#74b67bf3");

OfflineMapTask offlineMapTask = new OfflineMapTask(portalItem);

ListenableFuture&amp;lt;List&amp;lt;PreplannedMapArea&amp;gt;&amp;gt; future = offlineMapTask.getPreplannedMapAreasAsync();

future.addDoneListener(() -&amp;gt; {


try {
    List&amp;lt;PreplannedMapArea&amp;gt; preplannedMaps = future.get(); // &amp;lt;---- preplannedMaps  is EMPTY :-((((

   
} catch (InterruptedException | ExecutionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Question:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;What can be the Reason why the Preplanned Maps are empty ?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 10:13:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192718#M2596</guid>
      <dc:creator>ShawnKleese</dc:creator>
      <dc:date>2022-07-17T10:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192719#M2597</link>
      <description>&lt;P&gt;A quick answer as it's a Sunday... &amp;nbsp;there is a working sample app on &lt;A href="https://github.com/Esri/arcgis-runtime-samples-java/tree/main/map/download-preplanned-map" target="_self"&gt;gitHub&lt;/A&gt;&amp;nbsp;could take a look at. &amp;nbsp;It does pretty much the same as you are trying to do.&lt;/P&gt;&lt;P&gt;If that doesn't help then let me know and I'll take a closer look at your code on Monday.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 10:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192719#M2597</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2022-07-17T10:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192728#M2598</link>
      <description>&lt;P&gt;Hey Mark,&lt;/P&gt;&lt;P&gt;thank you for your Sunday-Attention &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Yes, i know this example and i have study it and all Documentions i found for the Offlinemaps-Topic.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to fix my code for a few hours, but there are no PreplannedMaps found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 13:59:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192728#M2598</guid>
      <dc:creator>ShawnKleese</dc:creator>
      <dc:date>2022-07-17T13:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192751#M2599</link>
      <description>&lt;P&gt;So i have started the Example-App with my License and my PortalItem/Map but i have the same Behavior - no PreplannedMaps Found:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShawnKleese_0-1658087081299.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/46007i089517D98340E6A9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShawnKleese_0-1658087081299.png" alt="ShawnKleese_0-1658087081299.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So Something is maybe not corrctly configured in the Arcgis-Backend?&lt;/P&gt;&lt;P&gt;But i have added the Offline Area:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShawnKleese_1-1658087356587.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/46008iB561755694704741/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShawnKleese_1-1658087356587.png" alt="ShawnKleese_1-1658087356587.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe you have tommorow some Idea...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 19:50:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192751#M2599</guid>
      <dc:creator>ShawnKleese</dc:creator>
      <dc:date>2022-07-17T19:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192837#M2600</link>
      <description>&lt;P&gt;Swapping out your service into our sample app shows there is likely to be a config issue on the server side as you have suggested.&amp;nbsp; At least it shows that your original code was probably okay.&lt;/P&gt;&lt;P&gt;Configuring ArcGIS Online services isn't something I do very often so I'm going to ask someone who knows this area better to see if they have any thoughts.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 09:23:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1192837#M2600</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2022-07-18T09:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1193352#M2601</link>
      <description>&lt;P&gt;Okay thinking about this more (and having discussed it with someone else too), I'm wondering if you issue is around authenticating against your webmap.&amp;nbsp; The webmap we are using in the sample is a public one so doesn't require any authentication to get you accessing it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering if you are able to open your web map and display it at all?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a sample which shows how to display a webmap from a portal item &lt;A href="https://github.com/Esri/arcgis-runtime-samples-java/tree/main/map/open-map-url" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp; If security is the issue , then you can take a look at these &lt;A href="https://github.com/Esri/arcgis-runtime-samples-java/tree/main/portal" target="_self"&gt;samples&lt;/A&gt; which might help.&lt;/P&gt;&lt;P&gt;Let me know how you get on with this&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 13:14:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1193352#M2601</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2022-07-19T13:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1193362#M2602</link>
      <description>&lt;P&gt;Hello Mark,&lt;/P&gt;&lt;P&gt;thank you for your investigations. Security is'nt the problem.&amp;nbsp; The Map is displayed in the sample App and also my app. I've added the Credentials just for hopping, that this might be the problem...&lt;/P&gt;&lt;P&gt;So in my opinon the Problem is in the Configuration of my Arcgis Offline Map Areas ( But this is very simple and not a big deal) and the other possibility is that there is a Bug somewhere?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 13:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1193362#M2602</guid>
      <dc:creator>ShawnKleese</dc:creator>
      <dc:date>2022-07-19T13:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1194036#M2605</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/603589"&gt;@ShawnKleese&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have a theory about what's going on.&lt;/P&gt;&lt;P&gt;Can you comment out your line of code that sets the global API Key on the ArcGISRuntimeEnvironment please and try that?&lt;/P&gt;&lt;P&gt;Here's what I think is happening:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Preplanned map areas are stored as hidden portal items that are related to the web map portal item (there's an &lt;STRONG&gt;area&lt;/STRONG&gt; item for each preplanned map area, and each area item itself has related &lt;STRONG&gt;package&lt;/STRONG&gt; items, all hidden).&lt;/LI&gt;&lt;LI&gt;The API Key might have access to the web map, but we don't yet automatically extend the API Key access to these related portal items.&lt;/LI&gt;&lt;LI&gt;By setting the global API Key on line 2, any Runtime object that doesn't have an explicit credential set will default to using that global API Key and bypass the authentication manager flow. I think that your OfflineTask can see the web map item, but cannot read the related area items to enumerate them.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;We need to update our API Key scoping logic to include these related area and package items when scoping an API Key for a web map.&lt;/P&gt;&lt;P&gt;In the meantime you could do a couple of things:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Do not set the API Key globally, but set it on each Runtime object that needs it.&lt;/LI&gt;&lt;LI&gt;Explicitly set your credential (from line 5 in your code) on your &lt;A href="https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/tasks/offlinemap/OfflineMapTask.html" target="_self"&gt;&lt;STRONG&gt;OfflineMapTask&lt;/STRONG&gt;&lt;/A&gt; with &lt;A href="https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/tasks/offlinemap/OfflineMapTask.html#setCredential(com.esri.arcgisruntime.security.Credential)" target="_self"&gt;&lt;STRONG&gt;setCredential()&lt;/STRONG&gt;&lt;/A&gt;. You should then be able to enumerate the preplanned areas. You will probably also need to &lt;A href="https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/concurrent/Job.html#setCredential(com.esri.arcgisruntime.security.Credential)" target="_self"&gt;set it&lt;/A&gt; on the &lt;A href="https://developers.arcgis.com/java/api-reference/reference/com/esri/arcgisruntime/tasks/offlinemap/DownloadPreplannedOfflineMapJob.html" target="_self"&gt;&lt;STRONG&gt;DownloadPreplannedOfflineMapJob&lt;/STRONG&gt;&lt;/A&gt; that you create from the OfflineMapTask&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Let us know if that helps.&lt;/P&gt;&lt;P&gt;If not, you should create a test web map that&amp;nbsp;&lt;EM&gt;is&lt;/EM&gt; entirely public and we can investigate further from there.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 16:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1194036#M2605</guid>
      <dc:creator>Nicholas-Furness</dc:creator>
      <dc:date>2022-07-20T16:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why getPreplannedMapAreasAsync returns empty List?</title>
      <link>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1194501#M2609</link>
      <description>&lt;P&gt;Hello Nicholas,&lt;/P&gt;&lt;P&gt;yes! You are absolutly right! After removing the Api Key and using just Credentials The ExampleApp and my App work!&lt;/P&gt;&lt;P&gt;But i think it would be great if it just works with the Api-Key.&lt;/P&gt;&lt;P&gt;Thank you for your Solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 16:45:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/java-maps-sdk-questions/why-getpreplannedmapareasasync-returns-empty-list/m-p/1194501#M2609</guid>
      <dc:creator>ShawnKleese</dc:creator>
      <dc:date>2022-07-21T16:45:33Z</dc:date>
    </item>
  </channel>
</rss>

