AnsweredAssumed Answered

Strange Magic In Layer List ... Bug?

Question asked by john_richardson_1969 on Nov 9, 2018
Latest reply on Nov 9, 2018 by john_richardson_1969

I have an application that has 4 layers that I want to stay available in my map at all times. In my layer list, they appear as follows:



The code that creates the layers follows:


var featurelayer = new FeatureLayer({ //adds a feature layer of 2018 Crime
url: "",
title: "2018 Crime",
renderer: crimeRenderer,
visible: false,
popupEnabled: false,
popupTemplate: crimePopupTemplate
map.add(featurelayer, 2);

var apdbeatsLayer = new FeatureLayer({ //adds a feature layer of APD Beats
url: "",
title: "APD Beats",
renderer: beatsRenderer,
popupEnabled: false,
popupTemplate: beatsPopupTemplate,
opacity: 0.5,
visible: false
map.add(apdbeatsLayer, 3);

var orthLayer = new ImageryLayer({ //adds an image layer of Orthos SCE
url: "",
title: "Ortho - East",
visible: false
map.add(orthLayer, 0);

var orthLayer2 = new ImageryLayer({ //adds an image layer of Orthos SCW
url: "",
title: "Ortho - West",
visible: false
map.add(orthLayer2, 1);


At any time, the user may choose a month from a menu, and a query runs against the 'featurelayer' and then displays only the crimes for that month in a new featurelayer :



Here you can see that I have added 4 months of crime data to the map, each layer a different color, and you can also see the layers show up in the layer list :



I have a radial menu, which has an icon to click to remove any added layers from the layer list, as it can get crowded quick:



The icon code for removing the added layers, and leaving the 4 default layers is as follows:


$("#ichyPic").click(function() {
var layLength = map.layers.length;

while (layLength > 4) {


If 4 or more layers have been added to the map, the code above eliminates all of the layers,but still leaves a straggler behind, at the bottom of the layer list ... this layer, as you can see in the picture below, is turned on, but nothing shows on the map ... the layer is not real, it just shows up ... I think this may be a bug?



Thank you!