Template Picker and layers not showing up

3143
0
07-10-2014 10:15 AM
AlexGole
Occasional Contributor II

Hi all,

I am trying to develop a web application that allows the users to visualize edits through time and allow users to edit online. Everything seems to work fine but the template picker does not allow show my layers somehow in the legend. Am I missing something here?

Thank you,

AlexCapture.PNG

   var featureLayer = new FeatureLayer("http://webgisdevint1/arcgis/rest/services/Alex_Try/Final/FeatureServer/0",{

          mode: FeatureLayer.MODE_ONDEMAND,

          outFields: ['*']

          });

  map.addLayers([featureLayer]);

  month = new Array();

  month[0] = "January";

  month[1] = "February";

  month[2] = "March";

  month[3] = "April";

  month[4] = "May";

  month[5] = "June";

  month[6] = "July";

  month[7] = "August";

  month[8] = "September";

  month[9] = "October";

  month[10] = "November";

  month[11] = "December";

        

  

  map.on("layers-add-result", initEditor);

  map.on("load", initEditor);

        function initSlider() {

          var timeSlider = new TimeSlider({

            style: "width: 100%;"

          }, dom.byId("timeSliderDiv"));

          map.setTimeSlider(timeSlider);

         

          var timeExtent = new TimeExtent();

          timeExtent.startTime = new Date("5/1/2014 UTC");

          timeExtent.endTime = new Date("12/31/2014 UTC");

          timeSlider.setThumbCount(1);

          timeSlider.createTimeStopsByTimeInterval(timeExtent, 2, "esriTimeUnitsWeeks");

          timeSlider.setThumbIndexes([0,1]);

          timeSlider.setThumbMovingRate(2000);

          timeSlider.startup();

         

          //add labels for every other time stop

          var labels = arrayUtils.map(timeSlider.timeStops, function(timeStop, i) {

  

    var n = month[timeStop.getMonth()];

            if ( i % 2 === 0 ) {

              return n;

            } else {

              return "";

            }

          });

         

          timeSlider.setLabels(labels);

          timeSlider.on("time-extent-change", function(evt) {

            var startValString = evt.month[startTime.getMonth()];

            var endValString = evt.month[endTime.getMonth()];

            dom.byId("daterange").innerHTML = "<i>" + startValString + " and " + endValString  + "<\/i>";

          });

        }

         symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

            new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([111, 0, 255]), 2), new Color([255, 255, 0, 0.25]));

         infoTemplate = new InfoTemplate("${OBJECTID}", "${*}");

         registry.byId("query").on("click", executeQuery);

         function executeQuery(name) {

           

  var name = document.getElementById("user").value;

  var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Final/FeatureServer/0");

  var query = new Query();

            query.returnGeometry = true;

            query.outFields = ["LAST_EDITED_USER"];

            query.where = "LAST_EDITED_USER = '" + name + "'";

            query.outSpatialReference = map.spatialReference;

            queryTask.execute(query, showResults);;

  }

         function showResults(featureSet) {

         //remove all graphics on the maps graphics layer

         map.graphics.clear();

         //Performance enhancer - assign featureSet array to a single variable.

         var features = featureSet.features;

         //Loop through each feature returned

         for (var i=0, il=features.length; i<il; i++) {

         //Get the current feature from the featureSet.

         //Feature is a graphic

         var graphic = features;

         graphic.setSymbol(symbol);

         //Set the infoTemplate.

         graphic.setInfoTemplate(infoTemplate);

         //Add graphic to the map graphics layer.

         map.graphics.add(graphic);

        }

       }

   

    function initEditor(evt) {

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

            return result.layer;

          });

          var templatePicker = new TemplatePicker({

            featureLayers: templateLayers,

            grouping: true,

            rows: "auto",

            columns: 2

          }, "templateDiv");

          templatePicker.startup();

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

            return { featureLayer: result.layer };

          });

          var settings = {

            map: map,

            templatePicker: templatePicker,

            layerInfos: layers,

            toolbarVisible: true,

            createOptions: {

              polylineDrawTools:[ Editor.CREATE_TOOL_FREEHAND_POLYLINE ],

              polygonDrawTools: [ Editor.CREATE_TOOL_FREEHAND_POLYGON,

                Editor.CREATE_TOOL_CIRCLE,

                Editor.CREATE_TOOL_TRIANGLE,

                Editor.CREATE_TOOL_RECTANGLE

              ]

            },

            toolbarOptions: {

              reshapeVisible: true

            }

          };

          var params = {settings: settings};   

          var myEditor = new Editor(params,'editorDiv');

          //define snapping options

          var symbol = new SimpleMarkerSymbol(

            SimpleMarkerSymbol.STYLE_CROSS,

            15,

            new SimpleLineSymbol(

              SimpleLineSymbol.STYLE_SOLID,

              new Color([255, 0, 0, 0.5]),

              5

            ),

            null

          );

          map.enableSnapping({

            snapPointSymbol: symbol,

            tolerance: 20,

            snapKey: keys.ALT

          });

   

          myEditor.startup();

        }

 

        

});

   </script>

Tags (1)
0 Kudos
0 Replies