Loading multiple TPK files on arcgis runtime sdk 100.0 (latest)

1629
5
Jump to solution
10-17-2017 03:44 AM
JasonChristian
New Contributor II

Hi,

I have checked out the example on how you load a custom tile package using Basemap class and setMap(). However, there's no indication on how you can load multiple Basemap class or ArcGISTiledLayer types

In the previous version of the runtime sdk (10.2.9), we can easily use Map.addLayer() to add layers, but I cannot find it anywhere on the MapView class on the latest sdk (I assume setMap() will just replace the previous one). We have quite a few of .tpk files stored in the device that we would want to display altogether

Is there anyway to load multiple tpk files? or is the feature not yet in the latest release?

Best regards,

Jason

0 Kudos
1 Solution

Accepted Solutions
AlexanderNohe1
Occasional Contributor III

If you just want to use them as basemap layers you could do something like this:

Basemap b = new Basemap();
b.getBaseLayers().addAll(layersCollection);
        
ArcGISMap arcGISMap = new ArcGISMap(b);

mapView.setMap(arcGISMap);‍‍‍‍‍‍

The layersCollection object would be of type Collection<? extends Layer> so you could create a list of layer objects and then load them into the basemap to then load into the mapview.

View solution in original post

5 Replies
AlexanderNohe1
Occasional Contributor III

Jason Christian‌,

On the map object, use the getOperationalLayers() and then use add(Layer layer) to add a layer to the operational layers list of the Map that is set in the mapview.

ArcGISMap| arcgis-android <-- Should be bookmarked to the getOperationalLayers() method.

Hope this helps!

Thanks,

Alexander

0 Kudos
JasonChristian
New Contributor II

Thank you for the response.

You actually need to give the map an instance of ArcGISMap first before accessing the map object from MapView.getMap() (It will be null originally if you don't provide a basemap through MapView.setMap()). Let's say we have 5 TPK files to be loaded. First thing to do is set the 1st TPK file inside the ArcGISMap object and add it using setMap() and then add the remaining 4 files as operational layers inside the ArcGISMap object (which contains the 1st TPK file). Is that how it works?

0 Kudos
AlexanderNohe1
Occasional Contributor III

If you just want to use them as basemap layers you could do something like this:

Basemap b = new Basemap();
b.getBaseLayers().addAll(layersCollection);
        
ArcGISMap arcGISMap = new ArcGISMap(b);

mapView.setMap(arcGISMap);‍‍‍‍‍‍

The layersCollection object would be of type Collection<? extends Layer> so you could create a list of layer objects and then load them into the basemap to then load into the mapview.

JasonChristian
New Contributor II

oh very neat. Thank you very much

0 Kudos
AlexanderNohe1
Occasional Contributor III

You're welcome!