AnsweredAssumed Answered

Remove graphic based on it's geometry

Question asked by abrown31 on Nov 9, 2012
Latest reply on Feb 7, 2017 by TikiLeBrock
Just to give you a heads up of what the viewer is doing:

Using identifyTask, a bunch of soil borings are queried and their attributes are displayed on a table at the bottom of a screen. Initially, all of the queried soil borings are highlighted on the map (symbols) and the records are selected (checked) in the table (dojox.grid.enhancedgrid with the indirectSelection plugin). What I need to have happen is, if the user deselects a row in the table, the corresponding soil boring needs to unselect itself.

For the code, since I have multiple layers, the soil borings are written to a specific array based on the queryResults.layerName
case "bore":                                         if (!arrayBore.displayFieldName) { arrayBore.displayFieldName = idResult.layerName };                                         arrayBore.geometryType = idResult.geometryType;                                         arrayBore.features.push(idResult.feature);                                         break;


And since the table contains tabs based on each layer selected, the "soil boring" tab is created with the results:
if (arrayBore.displayFieldName) {                                 newTab = new dijit.layout.ContentPane({ title: arrayBore.displayFieldName, content: layerTabContent(arrayBore, "arrayBore", type), closable: true, id: "tabBore", style: "overflow-y:auto" });                                 dijit.byId("tabs").addChild(newTab); //content is added to the table                             }


When the table is built, within function layerTabContent, I have two events: onSelected and onDeselected, which fire according to the user's interaction with the checkbox in the table.
Right now, this is what I have:
dojo.connect(resultGrid, 'onDeselected', function (rowId) {                 map.graphics.remove(layerResults.features[rowId]);             }); //connect


And it doesn't work. It doesn't throw any errors, but it just doesn't remove that specific graphic from the map. Could somebody help me figure out why a specific record's graphic isn't being removed from the map?

This is what the layerResults.features[rowId] object looks like within Chrome's debugger:

layerResults.features[rowId].geometry: Object spatialReference: Object type: "point" x: 468744.3380974941 y: 2011151.794075489 __proto__: Object


Sorry, I'm still new at Javascript, and I've been teaching myself everything thus far. I apologize for any ignorance.

Thanks,
Andrew

Outcomes