AnsweredAssumed Answered

infoTemplate not working in Select with Feature Layer sample

Question asked by GibbyAR on Oct 4, 2013
Latest reply on Oct 7, 2013 by GibbyAR
So I've implemented the Select with Feature Layer sample. The buffering, feature selecting with the buffer all work as expected. Query results are returned, graphic symbology is performed but when I click on a graphic within the buffer, the infoTemplate doesn't appear. Nothing happens. Related code is below.

var infraFeatureLayer = new FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0",{
          mode: FeatureLayer.MODE_SELECTION,
          infoTemplate: new InfoTemplate("Block: ${BLOCK}", "${*}"),
          outFields: ["POP2000","HOUSEHOLDS","HSE_UNITS", "TRACT", "BLOCK"]
        });

        // selection symbol used to draw the selected census block points within the buffer polygon
        var isymbol = new SimpleMarkerSymbol(
          SimpleMarkerSymbol.STYLE_CIRCLE,
          12,
          new SimpleLineSymbol(
            SimpleLineSymbol.STYLE_NULL,
            new Color([247, 34, 101, 0.9]),
            1
          ),
          new Color([207, 34, 171, 0.5])
        );
        infraFeatureLayer.setSelectionSymbol(isymbol);
        map.addLayer(infraFeatureLayer);

   gsvc = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

function fireInfra() {
   infraHandler = dojo.connect(map,"onClick",findInfrastructure); 
}

function findInfrastructure(evt) {
        var paramsI = new BufferParameters();
        paramsI.geometries  = [ evt.mapPoint ];
        paramsI.distances = [ 1 ];
        paramsI.unit = GeometryService.UNIT_STATUTE_MILE;
  gsvc.on("buffer-complete", function(){
      dojo.disconnect(infraHandler);
     });
        gsvc.buffer(paramsI, showInfraBuffer);
}

function showInfraBuffer(geometries) {      
      map.graphics.clear();
      // draw the buffer geometry on the map as a map graphic
      var symbol = new SimpleFillSymbol(
       SimpleFillSymbol.STYLE_NULL,
       new SimpleLineSymbol(
        SimpleLineSymbol.STYLE_SHORTDASHDOTDOT,
        new Color([105,105,105]),
        2
       ),new Color([255,255,0,0.25])
      );
   //end symbol
   var bufferGeometry = geometries[0]
      var graphic = new Graphic(bufferGeometry, symbol);
      map.graphics.add(graphic);
   //do query with buffer
   var query = new Query();
      query.geometry = bufferGeometry;
   query.returnGeometry = true;
      infraFeatureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(results){
     var popTotal = 0;
          for (var x = 0; x < results.length; x++) {
            popTotal = popTotal + results[x].attributes['POP2000'];
          }  
  alert(popTotal);
      });
}

Outcomes