AnsweredAssumed Answered

Unable to show layers in ArcGIS map after removing tiled map service layer

Question asked by bryan.sng on Dec 26, 2015
Latest reply on Dec 27, 2015 by bryan.sng

Hi,

I wish to create a function to change basemap.

To test the concept, I created a map and added a ArcGISTiledMapServiceLayer

var tiled = new ArcGISTiledMapServiceLayer('http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer'); 

Next, I will remove the layer and add a ArcGISImageServiceLayer to stimulate a change basemap action

var image = new ArcGISImageServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Toronto/ImageServer", { imageServiceParameters: params, opacity: 0.75 }); 

What I realised is after these [adding tiled, removing tiled, adding image] actions, no layers will be rendered

I tested other scenarios and these are the results:

1) If I do not remove the tiled layer, both layers get rendered 
2) If I add only image layer, image layer get rendered
3) If I add only tiled layer, tiled layer get rendered

Do you guys have any advice as to why I cannot perform a remove layer action?

To make this question understandable, I created a sample fiddle that can illustrate my case. Simply remove the removeLayer comment in the fiddle and run it. You will notice as mentioned, nothing will be rendered.

https://jsfiddle.net/82qjh0wg/

Outcomes