How do I get the extents for all sublayer?

159
1
10-03-2017 04:52 PM
jackcrawford
New Contributor

I'm new to the Java runtime. I'm trying to get the extent for each sublayer which I assumed would be available by calling 

getMapServiceSublayerInfo().getExtent() 

but
getMapServiceSublayerInfo()

always returns null.

I've tried with our map service and the ESRI sample service 

http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer

Guidance would be much appreciated.

Jack
0 Kudos
1 Reply
DanO_Neill
Occasional Contributor III

Hi Jack: You are explicitly loading the `ArcGISMapImageLayer` but not the sublayer.  

ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");
       
mapImageLayer.loadAsync();
mapImageLayer.addDoneLoadingListener(() -> {

    final ArcGISMapImageSublayer testSublayer = (ArcGISMapImageSublayer) mMapImageLayer.getSublayers().get(0);
    testSublayer.loadAsync();

    testSublayer.addDoneLoadingListener(() -> {

        ArcGISMapServiceSublayerInfo testInfo = testSublayer.getMapServiceSublayerInfo();

    });

});
0 Kudos