Display Layer View State

Features

  • ArcGISMap
  • MapView
  • LayerViewStateChangedListener
  • ArcGISTiledLayer
  • ArcGISMapImageLayer
  • ServiceFeatureTable
  • FeatureLayer

Developer Pattern

The addLayerViewStateChangedListener on MapView listens for LayerViewStateChangedEvent. To get the layer's view status, use method getLayerViewStatus().iterator().next() on event.

mMapView.addLayerViewStateChangedListener(new LayerViewStateChangedListener() {
    @Override
    public void layerViewStateChanged(LayerViewStateChangedEvent layerViewStateChangedEvent) {

        // get the layer which changed it's state
        Layer layer = layerViewStateChangedEvent.getLayer();

        // get the View Status of the layer
        // View status will be either of ACTIVE, ERROR, LOADING, NOT_VISIBLE, OUT_OF_SCALE, UNKNOWN
        String viewStatus = layerViewStateChangedEvent.getLayerViewStatus().iterator().next().toString();

        final int layerIndex = mMap.getOperationalLayers().indexOf(layer);

        // finding and updating status of the layer
        switch (layerIndex) {
            case TILED_LAYER:
                timeZoneTextView.setText(viewStatusString(viewStatus));
                break;
            case IMAGE_LAYER:
                worldCensusTextView.setText(viewStatusString(viewStatus));
                break;
            case FEATURE_LAYER:
                recreationTextView.setText(viewStatusString(viewStatus));
                break;
        }

    }
});