AnsweredAssumed Answered

Find Task

Question asked by burnaby on May 3, 2016
Latest reply on May 4, 2016 by burnaby

I'm creating my first custom widget using the find task. I can retrieve and display the attributes of the returned records but I'm having issues adding graphics to the map. I've created a graphicsLayer called resultsLayer and added it to the map but I keep getting the following error: TypeError: Cannot read property '_graphicsLayer' of undefined. . Any help is appreciated.

 

showFindResults: function(results){

   console.log("showFindResults");

 

   var markerSymbol = symbolJsonUtils.fromJson(this.config.symbols.simplemarkersymbol);

   var lineSymbol = symbolJsonUtils.fromJson(this.config.symbols.simplelinesymbol);

   var polygonSymbol = symbolJsonUtils.fromJson(this.config.symbols.simplefillsymbol);

   var resultItems = [];

   var result, attribs;

   array.forEach(results, function (result){

  

   var graphic = result.feature;

   attribs = result.feature.attributes;

   resultItems.push("Compkey: " + "<b>" + attribs.COMPKEY + "</b><br>");

   resultItems.push("Unitid: " + "<b>" + attribs.UNITID + "</b><br>");

   resultItems.push("Layer Name: " + "<b>" + result.layerName + "</b><br>");

   resultItems.push("<br>");

  

   switch (graphic.geometry.type)

   {

   case "point":

     graphic.setSymbol(markerSymbol);

  break;

   case "polyline":

    graphic.setSymbol(lineSymbol);

  break;

   case "polygon":

   graphic.setSymbol(polygonSymbol);

  break;

   }

     this.resultsLayer.add(graphic);

     //this.map.graphics.add(graphic);

   });

Outcomes