AnsweredAssumed Answered

map.on click produces multiple points with single mouse click

Question asked by mahaley844 on Nov 30, 2018
Latest reply on Nov 30, 2018 by rscheitlin

In JavaScript I have the following function used to place markers on the map and label them. The label offset is changed just so I could see what is going on. When I get it fixed the label offset will not change.

 

placeMarkers (){

if (dijit.byId("rdoMarkerMethodManual").checked) {

WUAapp.WUAmap.on("click", function (evt) {

markerPoint = null;

markerPoint = new esri.geometry.Point(evt.mapPoint.x, evt.mapPoint.y, new esri.SpatialReference({ wkid: 2903 }));

//var pointCoords = document.getElementById('txtMarkerMethodKeyin').value.split(',');

//markerPoint = new esri.geometry.Point(parseInt(pointCoords[0]), parseInt(pointCoords[1]), new esri.SpatialReference({ wkid: 2903 }));

WUAapp.WUAmap.graphics.add(new esri.Graphic(markerPoint, spotMarkerSymbol));

alert("spotMarker added");

 

//labelMarker(markerPoint);

 

if (dijit.byId("rdoLabelNumeric").checked) {

 

markerLabel = new esri.symbol.TextSymbol(currentMarkerLabel);

markerLabel.setOffset(labelOffset, 0);

labelPointGraphic = new esri.Graphic(markerPoint, markerLabel);

WUAapp.WUAmap.graphics.add(labelPointGraphic);

alert("Numeric Label " + labelCount + " added");

currentMarkerLabel = currentMarkerLabel + incrementInt;

labelCount = labelCount + 1;

labelOffset += 10;

 

}

 

----

This is called by a button on a form. It works fine the first time you push the button. However if you push the button again, a single mouse click will create 2 points and 2 labels. The third button push creates 3 points and three labels with a single mouse click. etc etc etc. I put the alerts in there to verify the points and labels have been placed.

 

Is there something that should be cleared?

Outcomes