jaybee18

Show featureset when clicking on several custom graphics

Discussion created by jaybee18 on Feb 18, 2011
Latest reply on Feb 23, 2011 by hzhu
I have the following code that loops through some JSON and draws points as graphics with infotemplates. Right now the default behavior is in effect, and clicking on a point shows the infowindow. I want to set this up so that if someone clicks on more than one point I use a different template, showing the list of links to features clicked on. The samples contain examples of this behaviour when using querytasks, but I'm not sure how to adapt that to my situation. Thanks!

/* draw a set of sightings as points on the map */
    function drawSightings(data) {
 map.graphics.clear();
 var point, colour, sighting;
 //draw the points
 for (var i=0; i < data.length; i++) {
     sighting = data[i];
     point = {"geometry":{"x": sighting.x,
     "y": sighting.y,
     "spatialReference": map.spatialReference},
       "attributes":{
    "number_observed": sighting.number_observed
       },
       "symbol":{
    "color": [255, 0, 0, 128],
    "size":12,
    "angle":0,
    "xoffset":0,
    "yoffset":0,
    "type":"esriSMS",
    "style":"esriSMSCircle",
    "outline":{
        "color":[0,0,0,255],
        "width":1,
        "type":"esriSLS",
        "style":"esriSLSSolid"
    }
       },
       "infoTemplate":{
    "title": " ${common_name} [${scientific_name}]",
    "content": "Number seen: ${number_observed}"
       }
      };
     graphic = new esri.Graphic(point);
     map.graphics.add(graphic);        
 }
    }

Outcomes