如何添加/删除ArcGISTiledMapServiceLayer

时间:2012-09-23 10:09:33

标签: android osmdroid

我有一张osmdroid地图。我要在它上面添加一个图层,它不是叠加层,它是一个图层。添加图层时没有问题,但是当我尝试删除图层时。有一个例外:

  

图层不是当前地图的子图层。

添加和删除图层的代码是:

如果(Layer_List_Adapter.toggle_status == TRUE)                 {

                    Log.i("ADDING LAYER... :", "Adding...");
                    mapView.addLayer(dmsl);
                    Log.i("Layers ::", ""+mapView.getLayers());
                    layer_added_falg=true;

            }

            else if(Layer_List_Adapter.toggle_status==false)
            {

                Log.i("A", "A");

                    if(layer_added_falg==true)
                    {
                    try
                    {
                        Log.i("REMOVING LAYER... :", "Removing...");
                        Log.i("Layers ::", ""+mapView.getLayers());
                        mapView.removeLayer(mapView.getLayerByID(layerId));
                        mapView.refreshDrawableState();
                        layer_added_falg=false;
                    }
                    catch (Exception e) {
                        // TODO: handle exception

                        Log.e("ERROR :", e.getMessage());
                    }
                    }

                    else
                    {

                    }

            }

0 个答案:

没有答案