Hello Everybody,
i'am struggeling arround with Preplanned offline Maps and need some help.
The Problem:
offlinemaptask.getPreplannedMapAreasAsync returns a Empty UnmodifiableList.
What i have Done before:
Environment/License:
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.
Code Snippet:
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<List<PreplannedMapArea>> future = offlineMapTask.getPreplannedMapAreasAsync();
future.addDoneListener(() -> {
try {
List<PreplannedMapArea> preplannedMaps = future.get(); // <---- preplannedMaps is EMPTY :-((((
} catch (InterruptedException | ExecutionException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} );
The Question:
What can be the Reason why the Preplanned Maps are empty ?
Solved! Go to Solution.
Hi @ShawnKleese,
I have a theory about what's going on.
Can you comment out your line of code that sets the global API Key on the ArcGISRuntimeEnvironment please and try that?
Here's what I think is happening:
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.
In the meantime you could do a couple of things:
Let us know if that helps.
If not, you should create a test web map that is entirely public and we can investigate further from there.
A quick answer as it's a Sunday... there is a working sample app on gitHub could take a look at. It does pretty much the same as you are trying to do.
If that doesn't help then let me know and I'll take a closer look at your code on Monday.
Mark
Hey Mark,
thank you for your Sunday-Attention 🙂
Yes, i know this example and i have study it and all Documentions i found for the Offlinemaps-Topic.
I have tried to fix my code for a few hours, but there are no PreplannedMaps found.
So i have started the Example-App with my License and my PortalItem/Map but i have the same Behavior - no PreplannedMaps Found:
So Something is maybe not corrctly configured in the Arcgis-Backend?
But i have added the Offline Area:
Maybe you have tommorow some Idea...
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. At least it shows that your original code was probably okay.
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.
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. The webmap we are using in the sample is a public one so doesn't require any authentication to get you accessing it.
I'm wondering if you are able to open your web map and display it at all?
There is a sample which shows how to display a webmap from a portal item here. If security is the issue , then you can take a look at these samples which might help.
Let me know how you get on with this
Hello Mark,
thank you for your investigations. Security is'nt the problem. 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...
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?
Hi @ShawnKleese,
I have a theory about what's going on.
Can you comment out your line of code that sets the global API Key on the ArcGISRuntimeEnvironment please and try that?
Here's what I think is happening:
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.
In the meantime you could do a couple of things:
Let us know if that helps.
If not, you should create a test web map that is entirely public and we can investigate further from there.
Hello Nicholas,
yes! You are absolutly right! After removing the Api Key and using just Credentials The ExampleApp and my App work!
But i think it would be great if it just works with the Api-Key.
Thank you for your Solution!