AnsweredAssumed Answered

add graphic to map

Question asked by rhyck.m on Aug 25, 2014
Latest reply on Aug 25, 2014 by rhyck.m

Hi all,

 

In my code I am trying to buffer a parcel and then highlight the parcels that interesect the buffer. the code works fine for the buffer and add the first graphic on the map. but after performing the query to add the second graphic, it won't work. I am not sure why!

here is my code:

// Listen for GeometryService onBufferComplete event
        dojo.connect(gsvc, "onBufferComplete", function(graphics) {
   var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
          var graphic = new esri.Graphic(graphics[0], symbol);
          map.graphics.add(graphic); // this one works fine...


          query.geometry = graphic.geometry;
   query.outSpatialReference = {"wkid":3754};
          queryTask.execute(query);
   map.setExtent(map.graphics.graphics[0].geometry.getExtent().expand(1.25));
        });


  // +++++Listen for QueryTask executecomplete event+++++
  dojo.connect(queryTask, "onComplete", function(fset) {
  dojo.byId('ResultsGoHere').innerHTML = " ";
  var resultFeatures = fset.features;


  var symbol = new esri.symbol.SimpleFillSymbol(
  "solid",
  new esri.symbol.SimpleLineSymbol(
  "none",
  new dojo.Color([0, 0, 255, 0.65]), 2),
  new dojo.Color([255, 0, 255, 0.35]));


  var noOfPolys = resultFeatures.length;
  var graphic2, i;
  // run this for loop to highlight the parcels
  for (i = 0; i < noOfPolys; i++) {

  graphic2 = new esri.Graphic(resultFeatures[i].geometry, symbol);
  map.graphics.add(graphic2); //here no graphics added to the map;
  }

  }


Outcomes