AnsweredAssumed Answered

highlight point from dGrid selection - graphics not displaying, API reference issue?

Question asked by schlot on Sep 27, 2013
Latest reply on Sep 27, 2013 by kenbuja
I have a query that executes to populate a dGrid.  I'd like to be able to click on a row in the grid and highlight the feature on the screen.  Since the row doesn't have any knowledge of the geometry, I have a 2nd query.  This query is executing just fine, but I'm having troubles creating the graphic and adding it to either the map graphics or a graphicsLayer.  I don't much care which, I think my problem is in the definition of the graphic  I haven't been using AMD very long, so maybe I'm getting a little lost there.  I'm confused by the fact that some examples and API references show dojo.require of "esri/graphic" and others are "esri/Graphic".  Is that just an error? Only esri/graphic seems to work.

Plus the API reference for Graphic lists geometry, symbol, attributes and infoTemplate all as required elements in the constructor.  But lots of examples only have geometry and symbol or even just geometry.  Why all the inconsistency?


function highlightGridSelection(event, dGrid) {
    selGraphicsLayer.clear();
    var row = dGrid.row(event);
    var query = new esri.tasks.Query();
    var schName = [row.data.facility];
    var cityName = [row.data.city];
    query.where = "Facility = '" + schName + "' and " + "City = '" + cityName + "'";
    query.returnGeometry = true;
    query.outFields = ["*"];
    query.outSpatialReference = spatialReference;
    var queryTask = new esri.tasks.QueryTask(educationLayer.url+"/0");
    queryTask.execute(query, highlightResults);
}  

function highlightResults(results) {
    if (results) {//Note:  I am consistently getting results from the query task, it's not like it's blank
      var feature = results.features[0];//already esri.Graphic?
      var graphic = new Graphic(feature.geometry, highlightMarkerSymbol);  //this seems to be the problem line 
      selGraphicsLayer.add(graphic);//
   //  app.map.graphics.add(graphic);
    } else {
        console.log("No records found");
    }
}

Outcomes