I had the same issue with order of the layers in the TemplatePicker. After every refresh, the layers are ordered differently. The order of the layers in 'evt' (in the line 'function initEditor(evt)') is not always the same. So when mapping these layers: var layers = array.map(evt.layers, function (result) { return result.layer; }); you could add a sort(), in your case based on layerId: var layers = array.map(evt.layers, function (result) { return result.layer; }).sort(function (obj1, obj2) { return obj1.layerId - obj2.layerId; }); In my case the layerIds (no relations with the order in which they are added to the map) where not applicable, so I had to add a property (displayOrder) to the layers (after line 120 above, just after constructing the layers): trafficStudy1.displayOrder = 0; trafficStudy2.displayOrder = 1; trafficStudy3.displayOrder = 2; Then I could use this property to sort the layers: var layers = array.map(evt.layers, function (result) { return result.layer; }).sort(function (obj1, obj2) { return obj1.displayOrder - obj2.displayOrder; });
... View more