AnsweredAssumed Answered

Help with events

Question asked by jamesfreddyc on Aug 8, 2018
Latest reply on Aug 8, 2018 by jamesfreddyc

Simple scenario: a single html page with javascript.  Two buttons to perform simple actions when user clicks on a feature in the map: delete selected and save selected.

 

I'm not sure if I'm implementing this correctly (as it does work somewhat) but it seems that the initial button click even does not deactivate.  That is, if I click the button to delete a feature, move the cursor into the map and click a feature it correctly deletes as desired.  However, if I immediately click the second button to save, move the cursor into the map and click a different feature, it attempt to first delete (as if the first event is still active?).

 

Hope that makes sense.

 

1. "delete-poly-btn" initially activated and correctly deletes when a graphic feature is selected.

2. "save-poly-btn" then activated and first tries to perform deleteSelectedPolygon() function, then uploadSelectedPolygon() function.

 

document.getElementById("delete-poly-btn").onclick = function () {
        deleteSelectedPolygon();
    };
document.getElementById("save-poly-btn").onclick = function () {
        uploadSelectedPolygon();
    }
   
function deleteSelectedPolygon() {
        map.on("click", function (evt) {
        //code here to perform selection on click and delete graphic
       })
}; 

function uploadSelectedPolygon() {
        map.on("click", function (evt) {
        //code here to perform selection on click and save to feature service
       })
};

Outcomes