AnsweredAssumed Answered

mapImageLayer.GetSubLayers() failing when using map service

Question asked by Gratefuljamhead on Apr 26, 2017
Latest reply on Apr 27, 2017 by ANohe-esristaff

I am woefully green when it comes to using Android and the ESRI Android SDK (100.0.0). I apologize in advance for my greenhorn questions.

 

So I am looking to display a map service made of multiple layers in a simple Android app, I am current in my studio and gradle etc, as of last night (04/26/2017). I can handle the switch statements to change them but this issue I am running into is in actually getting them to display. 

 

Here is the map service in question: 

https://gis-server-02.usc.edu:6443/arcgis/rest/services/pjconner/fisheriesLandings/MapServer 

 

I am currently building off of the Change Sublayer Visibility sample app hosted here on github:

arcgis-runtime-samples-android/change-sublayer-visibility at master · Esri/arcgis-runtime-samples-android · GitHub

 

The problem I am running into is that when I go to get/set the visibility on a specific sublayer, I get index out of range exceptions because I assume the GetSublayers method is failing. I am not sure why this is the case. 

 

My current code is set up almost identical to the map initialization and layer set block in the example. 

 

// inflate MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);

// create a map with the Basemap Type topographic
ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 27.763528, -82.543717, 6);

// create a MapImageLayer with dynamically generated map images
mMapImageLayer = new ArcGISMapImageLayer(getResources().getString(R.string.landings_service_url));
mMapImageLayer.setOpacity(0.5f);

// add world cities layers as map operational layer
map.getOperationalLayers().add(mMapImageLayer);

// set the map to be displayed in this view
mMapView.setMap(map);

// get the layers from the map image layer
mLayers = mMapImageLayer.getSublayers();

//This is the line where the error occurs
mLayers.get(0).setVisible(true);

 

 

Despite the service displaying by default, it still doesn't show. So I figure I may have to manually set the visibility. As stated above. GetSubLayers seems to fail which leads to Null index exceptions when trying to force the layer visibility. Is this something wrong with my service, my code? 

 

I would be truly grateful for any help!

Outcomes