harchet

Creating a custom FeatureLayer from a findTask

Discussion created by harchet on Nov 9, 2012
Latest reply on Nov 12, 2012 by harchet
Hello,

I want to create a map that is similar to this, but instead of retrieving the information from a static FeatureLayer I want to create one with the data obtained in a findTask.

So depending on the find task the colored areas should change. This is the code I have:
function do_search(e){
            if (e.keyCode == 13) // 13 = enter key
            {
              findParams.searchText = dojo.byId('search').value;
       findTask.execute(findParams,zoomInSearch);
            }
  }
  function zoomInSearch(results){
    //This function works with an array of FindResult that the task returns
           map.graphics.clear();
    var items = dojo.map(results,function(result){
             var graphic = result.feature;
             //graphic.setSymbol(symbol);
             map.graphics.add(graphic);
             return result.feature.attributes;
           });
    //Create data object to be used in store
           var data = {
             identifier: "OBJECTID",  //This field needs to have unique values
             label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
             items: items
           };
          //Create data store and bind to grid.
          store = new dojo.data.ItemFileReadStore({ data:data });
          // I want to use this data to creae a Feature layer so it can be shown in the map, somehow


Or could I create a dataSource from the findTask, so I could create something similar to this example


Any idea?

Many thanks

Outcomes