hello , How Can I hide an object of type ArcGISDynamicMapServiceLayer ?? I

4520
22
11-14-2014 09:13 AM
LourdesOlvera
New Contributor

hello , How Can I hide an object of type ArcGISDynamicMapServiceLayer ??

I used : dynamicLayer.setVisible(false);  but does not work.

this is my code:

public void solar(View button){

  String dynamicMapURL = "http://iner.energia.gob.mx:6080/arcgis/restp/services/INER/SOLAR_GLOBAL/MapServer";

  ArcGISDynamicMapServiceLayer dynamicLayer = new ArcGISDynamicMapServiceLayer(

  dynamicMapURL);

  dynamicLayer.setVisible(true);

  if(geocap.getVisibility()==View.GONE){

  geocap.removeAllViews();

      geocap.setVisibility(View.VISIBLE);

      solar();

  }else{

  geocap.setVisibility(View.GONE);

  dynamicLayer.setVisible(false);

  }

  }

0 Kudos
22 Replies
MengyiGuo
Occasional Contributor

I think this is because you set the layer invisible, but it is for the layer instance. To actually see it invisible in the view, you probably want to get the layer from Mapview and set it invisible.

For example:

MapView mv = new MapView(this);
mv
.addLayer(new ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapSer..."));

Then you can use mv.getLayer(int index) to get the ArcGISDynamicMapServiceLayer and set it invisible.

0 Kudos
LourdesOlvera
New Contributor

Hello , the problem is this code , where is this painting a map on a base map. " GeoCap " is a reference table accompanying the map to be painted . I want the base map is active when it is quite another map .

Sorry for my bad English .

ArcGISDynamicMapServiceLayer capa1=new ArcGISDynamicMapServiceLayer("http://.......");

if(geocap.getVisibility()==View.GONE){

geocap.setVisibility(View.VISIBLE);

capa1.setVisible(true);

mMapView.addLayer(capa1);

}else{

geocap.setVisibility(View.GONE);

//capMap.setVisibility(View.GONE);

capa1.setVisible(true);

}

}

0 Kudos
MengyiGuo
Occasional Contributor

Do you mean GeoCap is another MapView or another Layer?

0 Kudos
LourdesOlvera
New Contributor

GeoCap is a callout that accompanies the map when is activated . this map is activated by a button. the problem is I can not hide the map , it stays active on the base map.

0 Kudos
MengyiGuo
Occasional Contributor

So you mean you want to hide ArcGISDynamicMapServiceLayer

Is that correct?

0 Kudos
LourdesOlvera
New Contributor

yes, but when I apply capa1.setVisible ( false); the map remains active on the base map

0 Kudos
MengyiGuo
Occasional Contributor

I tested the following code it works fine.

mMapView = (MapView) findViewById(R.id.map);

ArcGISDynamicMapServiceLayer dl = new ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/MapServer");

mMapView.addLayer(dl);

dl.setVisible(false);

if you comment the last line out, you can see a small tree in the middle of the map, and when you set it invisible, you will be able to see basemap, but not the dynamicLayer.

Please feel free to checkout the sample here:

Rachel-Android-Sample/SetVisible at master · guo7711/Rachel-Android-Sample · GitHub

0 Kudos
LourdesOlvera
New Contributor

HI !! My mistake was silly , just wrote the ArcGISTiledMapServiceLayer as global variables ¡JAJA!.

Now there is another problem , I have several base maps containing submaps or layers. Basemaps the extract from a url that ends in " / MapServer " layers or submaps have url with "/ MapServer / 14 " , for example, but these non submaps can paint as I do with the base maps. How do I make submaps be painted ?

0 Kudos
MengyiGuo
Occasional Contributor

URL like http:// <catalog-url>/<serviceName>/MapServer is a Map Service. And URL like http:// <mapservice-url>/layers represents all the layers and stand-alone tables under a map service published using ArcGIS for Server. It provides basic information about the layers and tables such as name, type, parent and sub-layers, fields, min and max scales, extent, and copyright text. Do you mean that you want to add a certain layer to your map? What type is your layer?

0 Kudos