Load select layers into templatePicker

507
2
04-02-2014 07:24 AM
williamcarr
Occasional Contributor II
Greetings,

I'm throwing together an app to add a series (107) feature layers for the attribute inspector. I also have a Editor/Template for adding point features. The problem is that the template picks up all the feature layers that are loaded.

var templateLayers = arrayUtils.map(evt.layers, function(result){
            return result.layer;


Is there a way to only display a couple feature layers for the template picker? I don't want to clutter the content pane and REALLY don't want anybody contaminating the other feature layers. I've checked samples and examples all day but, no joy.

Any ideas?
0 Kudos
2 Replies
TimCollyer
Occasional Contributor
Sounds like you want to use filter instead of map?

http://dojotoolkit.org/reference-guide/1.9/dojo/_base/array.html#filter

I think your code would look something like this

var templateLayers = arrayUtils.filter(evt.layers, function(result){
                        return result.layer.id == "id of layer you want";
                    });
0 Kudos
williamcarr
Occasional Contributor II

Found the answer after a couple more looks at it.

I pulled the

    var templateLayers = arrayUtils.map(evt.layers, function(result){

            return result.layer;

out completely. and changed

featureLayers: templateLayers,

to

featureLayers: [layer,layer2,layer3]

Tim's filter worked, but I was running too many layers(my best guess) and it was causing a timeout.

Cheers.

0 Kudos