I am adding several layers (both dynamic and tiled) programmatically to my map. In the layer-add-result event, I am setting the visibility to false and the visibleLayers to -1 for all the layers.
map.on("layer-add-result", function (addedLayer) { addedLayer.layer.setVisibility(false); addedLayer.layer.setVisibleLayers([-1]); });
However, when I create the map with a basemap, the basemap layer( or layers, since some basemaps have multiple layers) will also fire this event. Since I want to keep the basemap visible, how can I determine if the layer a basemap?
Solved! Go to Solution.
Ken,
Why not use Object.prototype.toString.call(addedLayer.layer)?
Robert Scheitlin, GISPI must be missing something. I tried that line but only got back the string "[object Object]"
var test = Object.prototype.toString.call(addedLayer.layer);
Ken,
Sorry I thought that this was a method of getting the exact object class name, but It will only give you the JavaScript Basic types (i.e Object.prototype.toString.call(new Date); // "[object Date]").