harchet

Highlight a feature when we click it

Discussion created by harchet on Feb 7, 2013
Latest reply on Feb 7, 2013 by dcastano
Hello,

I have a map that triggers an info window when clicked in some special features. I want to highlight them when we click in some of those features. The thing is that I created and onClick listener that works in all the map except for the features that contains an infowindow (it looks like the only thing that triggers the event in those features is the infowindow). This is the function I execute to identify the different features, I want to add an event so that when one of them is clicked I will get and infowindow and the feature highlighted (with a diferent color or blink)

function queryResults (results){
  for (var i=0, il=results.features.length; i<il; i++) {
var feature = results.features[i];
var meas = "";
//colour each element
if (colorSquema[feature.attributes["SPAT_NAME"]]){
   //create the string with the different measurements and distances
   for (var k=0; k<colorSquema[feature.attributes["SPAT_NAME"]]["measurements"].length; k++ ){
  meas = meas+colorSquema[feature.attributes["SPAT_NAME"]]["measurements"][k]["distance"]+"/"+colorSquema[feature.attributes["SPAT_NAME"]]["measurements"][k]["device"]+': '+colorSquema[feature.attributes["SPAT_NAME"]]["measurements"][k]["value"]+"<br/>";
   }
   //Create the poUp window for each element
   var infoTemplate = new esri.InfoTemplate("</b>${SPAT_NAME}<br/>",
              "<b>Sector:</b>"+colorSquema[feature.attributes["SPAT_NAME"]]["sector"]+"<br/>"+
              "<b>Relative Position:</b>"+colorSquema[feature.attributes["SPAT_NAME"]]["relPos"]+"<br/>"+
              "<b>Time:</b>"+colorSquema[feature.attributes["SPAT_NAME"]]["time"]+"<br/>"+
              "<b>Comments:</b>"+colorSquema[feature.attributes["SPAT_NAME"]]["comments"]+"<br/>"+
              "<b>Measurements: </b><br/>"+meas+
              "<br/>");

   if (colorSquema[feature.attributes["SPAT_NAME"]]["measurement"] < 2.5){
  feature.setSymbol(white);
   }
   else if (colorSquema[feature.attributes["SPAT_NAME"]]["measurement"] < 15){
  feature.setSymbol(blue);
   }
   else if (colorSquema[feature.attributes["SPAT_NAME"]]["measurement"] < 50){
  feature.setSymbol(green);
   }
   else if (colorSquema[feature.attributes["SPAT_NAME"]]["measurement"] < 2000){
  feature.setSymbol(yellow);
   }
   else if (colorSquema[feature.attributes["SPAT_NAME"]]["measurement"] < 100000){
  feature.setSymbol(orange);
   }
   else if (colorSquema[feature.attributes["SPAT_NAME"]]["measurement"] > 100000){
  feature.setSymbol(red);
   }
}
feature.setInfoTemplate(infoTemplate);
map.graphics.add(feature);
  }
}


Is there another way of doing this?

Thanks in advance

Outcomes