Manage Operational Layers


The sample demonstrates how to add, remove and reorder operational layers in a map


  • ArcGISMap
  • ArcGISMapImageLayer
  • MapView
  • LayerList

How to Use

Two map image layers are already added to the map in this sample. When you launch this sample you will see a MapView with a basemap and the two operational layers on it. When you press the **Operational Layers** button the sample switches to the second activity where you will see two lists. One which shows all the operational layers added to the map and the other which shows the layers that have been removed from the map. In the Added Layers list you can tap and delete the layer from the map, or long press and change the order in which the layers are added on to the map. In the Removed Layers list you can tap and add the layer back to the map.

Developer Pattern

LayerList represents the operational layers of a Map or the base or reference layers of a Basemap. when the layers in the list are rendered in a MapView, the changes in the list have an immediate effect on how these layers are rendered in the MapView.

private LayerList mMapOperationalLayers;
// get the LayerList from the Map
mOperationalLayers = mMap.getOperationalLayers();
// remove layer from map
// add layer to the map


 * Copyright (C) 2013 The Android Open Source Project
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package com.esri.arcgisruntime.sample.listviewdragginganimation;

import android.content.Context;
import android.os.Build;
import android.widget.ArrayAdapter;

import java.util.HashMap;
import java.util.List;

public class StableArrayAdapter extends ArrayAdapter<String> {

    final int INVALID_ID = -1;

    HashMap<String, Integer> mIdMap = new HashMap<String, Integer>();

    public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) {
        super(context, textViewResourceId, objects);
        for (int i = 0; i < objects.size(); ++i) {
            mIdMap.put(objects.get(i), i);

    public long getItemId(int position) {
        if (position < 0 || position >= mIdMap.size()) {
            return INVALID_ID;

        try {
            String item = getItem(position);
            return mIdMap.get(item);
        } catch (IndexOutOfBoundsException e) {
            return position;

    public boolean hasStableIds() {
        return android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M;