AnsweredAssumed Answered

Android SDK's MapView removeLayer method not working

Question asked by daniel.gray on Jun 16, 2015
Latest reply on Jun 17, 2015 by MGuo-esristaff

I'm currently exploring ArcGIS's Android SDK.

 

However, I've found that when adding a ShapefileFeatureTable to a FeatureLayer:

        FeatureLayer featureLayer = new FeatureLayer(shapefileFeatureTable);

        featureLayer.setRenderer(new SimpleRenderer(new SimpleFillSymbol(

                getResources().getColor(android.R.color.holo_blue_bright),

                SimpleFillSymbol.STYLE.SOLID)));

        mapView.addLayer(featureLayer);

and then trying to remove it:

        mapView.removeLayer(featureLayer);

it doesn't work! (the layer is still visible)

 

I've tried to change the following:

        mapView.addLayer(featureLayer,0);

        mapView.removeLayer(0);

and this doesn't work either.

 

EXPLANATORY NOTE: I'm trying to add and remove the feature layer because I want to show a GraphicsLayer on the map, but if I don't load a FeatureLayer first, the MapView stays completely black.  I tried to set the SpatialReference and the background grid, but the only thing that worked was adding a bogus FeatureLayer first.  I eventually "fixed it" by calling:

    mapView.addLayer(featureLayer);

    featureLayer.setVisible(false);

But I still think it's suboptimal solution.  Any ideas??

Outcomes