Creating a custom FeatureLayer from a findTask

1871
3
11-09-2012 03:22 AM
IonPadilla
New Contributor
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
0 Kudos
3 Replies
IonPadilla
New Contributor
Up, I really need to do solve this
0 Kudos
JohnGravois
Frequent Contributor
have you considered working with featureLayer.selectFeatures() instead of setting up a findTask?
0 Kudos
IonPadilla
New Contributor
Ok, this looks like what I want, now I need to find a way of iterating through the fields, this should be easy.

Thank you so much
0 Kudos