Select to view content in your preferred language

AddLayer after OnCreate NOT working. BUG?

1764
10
05-13-2013 01:42 AM
JessicaSena
Emerging Contributor
Hi,

I'm experimenting a weird behaviour with map.addLayer() method and I'm not sure if it's a bug or I'm missing something.

The thing is that in some Android devices (i.e. Samsung Galaxy Ace) when I add layers to the map after the OnCreate method these layers are not showing in the map, but if I add the layers during the onCreate method, these layers are showing correctly.

I could guess that you can only use the addLayer method on the OnCreate process, but it has no sense because as I say, this only happens in some Android devices... and that's why I'm not getting which is the exact problem.

These are two examples about 2different ways of how I add the layers:

map.removeAll();
WMSLayer wms = new WMSLayer("http://mapcache.icc.cat/map/bases/service?",SpatialReference.create(23031));
map.addLayer(wms);


or

baseLayer.setVisible(false);//I set to not visible the current layer added to the map
WMSLayer wms = new WMSLayer("http://mapcache.icc.catmapbasesservice?",SpatialReference.create(23031));
map.addLayer(wms);


Anyone has noticed the same? Anyone from ESRI could try to reproduce the problem?

Thanks in advanced,
0 Kudos
10 Replies
DanO_Neill
Deactivated User
Thanks Jessica for detailing your workflow and use case.  I can assure you that it is supported.  I tried to reproduce your issue on a Galaxy Note II with the specs below, but the app worked as expected.  Here is the code I used:

 public boolean onOptionsItemSelected(MenuItem item) {
  // handle item selection
  switch (item.getItemId()) {
  case R.id.World_Street_Map:
   mMapView.removeAll();
   mMapView.addLayer(basemapStreet);   
   return true;
  case R.id.World_Topo:
   mMapView.removeAll();
   mMapView.addLayer(basemapTopo); 
   return true;
  case R.id.NatGeo:
   mMapView.removeAll();
   mMapView.addLayer(basemapNatGeo); 
   return true;
  case R.id.Ocean_Basemap:
   mMapView.removeAll();
   mMapView.addLayer(basemapOcean); 
  default:
   return super.onOptionsItemSelected(item);
  }
 }


Device specs that I tested on:
Hardware: Verizon Samsung Galaxy Note II
Model number: SCH-I605
Android version: 4.1.1
Build number: JRO03C.I605VRALL4
Kernel version: 3.0.31-414933 se.infra@SEP-79 #1 SMP PREEMPT Fri Dec 28 21:21:38 KST 2012

The Android version is different and I suspect the kernel version will be as well.  The carrier is Verizon, what carrier are you using as there are some differences in carrier models.  This may have something to do with the issue as the fix may be in the device.  Is it possible for you to update to Android 4.1.2 and see if that resolves it? 

Concerning your workflow:  Have you created the option to manually add layers to the map with a user input URL?  That should work and I am interested in your experience.  We have a similar workflow in our ArcGIS App whereby users can input a URL to make a GIS Connection.  The ArcGIS App is wholly built with the SDK.
0 Kudos