What is the syntax for layer-add-result in the map object?

4578
3
Jump to solution
04-17-2014 08:13 AM
TracySchloss
Frequent Contributor
A lot of the events for the map don't have any input parameters, but it looks like layer-add-result does.  In the documentation, it says that the layer-add-result fires when you add the specified layer.  But what is the syntax for this?  I want to be able to see specifically when a particular layer is added, not just the plural version, layers-add-result.
0 Kudos
1 Solution

Accepted Solutions
JonathanUihlein
Esri Regular Contributor
The 'layer-add-result' event actually returns the layer that was added to the map in the callback.

You would have to check in the callback which layer was added and then do something based on that.

http://jsfiddle.net/tE4A3/7/


    on(map, "layer-add-result", function(layerAdded, errorMsg){                if(layerAdded.layer === myLayer){             console.log('found the layer i want, do something specific');            }     });

View solution in original post

0 Kudos
3 Replies
JonathanUihlein
Esri Regular Contributor
The 'layer-add-result' event actually returns the layer that was added to the map in the callback.

You would have to check in the callback which layer was added and then do something based on that.

http://jsfiddle.net/tE4A3/7/


    on(map, "layer-add-result", function(layerAdded, errorMsg){                if(layerAdded.layer === myLayer){             console.log('found the layer i want, do something specific');            }     });
0 Kudos
TracySchloss
Frequent Contributor
That makes sense, thanks!
0 Kudos
AndrewRowe
New Contributor
The 'layer-add-result' event actually returns the layer that was added to the map in the callback.

You would have to check in the callback which layer was added and then do something based on that.

http://jsfiddle.net/tE4A3/7/


    on(map, "layer-add-result", function(layerAdded, errorMsg){       
        if(layerAdded.layer === myLayer){
            console.log('found the layer i want, do something specific');   
        }
    });


Just what I needed!  Thanks for that.
0 Kudos