AnsweredAssumed Answered

Problem Switching between ArcGISTiledMapServiceLayer, first one always loads.

Question asked by omega_cancer on Mar 5, 2015
Latest reply on Sep 17, 2015 by hassanjamil_magma

I want to add two ArcGISTiledMapServiceLayer in my mapView. It seems that only one that gets added first to mapView is loading, later one does not get displayed.

 

Do anybody face problem switching between two ArcGISTiledMapServiceLayers.

Is there any limit to have only one ArcGISTiledMapServiceLayer in map.  I have tried removing the layer too.

Here is what I am doing

 

 Button b1 =null;
    Button b2 =null;
    MapView mMapView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mMapView = (MapView)findViewById(R.id.map);
        b1 =(Button) findViewById(R.id.button);
        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMapView.removeAll();
                ArcGISTiledMapServiceLayer tileLayer1 = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/arcgis/rest/services/ESRI_StreetMap_World_2D/MapServer");
                mMapView.addLayer(tileLayer1);
                mMapView.setMaxExtent(tileLayer1.getFullExtent());
                mMapView.setMinScale( tileLayer1.getMinScale());
                mMapView.setMaxScale(tileLayer1.getMaxScale());
            }
        });
        b2 =(Button) findViewById(R.id.button2);
        b2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMapView.removeAll();
                ArcGISTiledMapServiceLayer tileLayer = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer");
                mMapView.addLayer(tileLayer);
                mMapView.setMaxExtent(tileLayer.getFullExtent());
                mMapView.setMinScale( tileLayer.getMinScale());
                mMapView.setMaxScale(tileLayer.getMaxScale());
            }
        });
}

 

<!-- MapView -->
    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="tileLayer1"
        android:id="@+id/button"
        android:layout_gravity="bottom" />
    <com.esri.android.map.MapView
        android:id="@+id/map"
        android:layout_width="134dp"
        android:layout_height="405dp"
        android:layout_weight="4" />
    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="tileLayer"
        android:id="@+id/button2"
        android:layout_gravity="bottom" />

 

 

tileLayer does not get loaded and tileLayer1 always gets loaded when I click on tileLayer button and vice versa.

Please guide me.

Outcomes