Hey guys, im fairly new to the javascript API.
I made a viewer where the user is able to draw and edit shapes and text. I am trying to figure out how to remove a single graphic that is selected.
the code below removes all graphics regardless if its selected or not. anyideas on what Im doing wrong?
map.graphics.on("click", function(evt){
//window.alert("click caught");
event.stop(evt);
editingEnabled = true
if (evt.ctrlKey === true || evt.metaKey === true) { //delete feature if ctrl key is depressed
window.alert("delete caught");
map.graphics.clear(); // removes all graphics as opposed to only selected graphic
currentLayer = this;
editToolbar.deactivate();
editingEnabled=false;
}
});
//FIXED CODE (thanks to tim witt) - just in case anyone came accross the same issue.
map.graphics.on("click", function(evt){
//window.alert("click caught");
event.stop(evt);
editingEnabled = true
if (evt.ctrlKey === true || evt.metaKey === true) { //delete feature if ctrl key is depressed
window.alert("delete caught");
map.graphics.remove(evt.graphic); // this removes single graphic
currentLayer = this;
editToolbar.deactivate();
editingEnabled=false;
}
});