How can I remove a graphic using an attribute? I am able to add the graphic.
view.graphics.graphics.length is invalid. I am having a hard time finding what I need in the view object because of all the _proto_ levels.
//*************************************************//
//** show Graphic for selected feature **//
//*************************************************//
function showGraphic(myID) {
if (arrayIdFeatures.length) {
for (i = 0; i < arrayIdFeatures.length; i++) {
if (arrayIdFeatures.attributes['Legend ID'] == myID) {
var pointAtt = {
"LegendID": arrayIdFeatures.attributes['Legend ID']
};
var pointGeography = arrayIdFeatures.geometry;
var pointGraphic = new Graphic({
geometry: arrayIdFeatures.geometry,
symbol: pointSymbol,
attributes: pointAtt
});
view.graphics.add(pointGraphic);
} // end if stmt
} // end for stmt
} //end if stmt
} // end function showGraphic()
//*************************************************//
//** remove Graphic for selected feature **//
//*************************************************//
function removeGraphic(myID) {
if (view.graphics.graphics.length) {
for (i = 0; i < view.graphics.graphics.length; i++) {
if (view.graphics.graphics.attributes.LegendID == myID) {
view.graphics.remove(view.graphics.graphics);
} // end if stmt
} // end for stmt
} //end if stmt
} // end function removeGraphic()