AnsweredAssumed Answered

help click

Question asked by jose@apiAG on May 23, 2018

Hello everyone,
I need a little help, how to recognize the event click on several points?

This is my code:

 

var prov=71;

for (var i = 0; i < pointsProvincias.length; i++) {
   var pointP = new Point({
   longitude: pointsProvincias[i][0],
   latitude: pointsProvincias[i][1]
});


var PsymbolP = new PictureMarkerSymbol({
   url: "imgs/GM-ico-INE.png",
   width: "35px",
   height: "35px"
});

 

var pointGraphicP = new Graphic({
   geometry: pointP,
   symbol: PsymbolP,
   id: prov
});


view.graphics.add(pointGraphicP);
prov = prov + 1;
view.on("click", eventHandlerP);

//end for

}

function eventHandlerP(event) {
   view.hitTest(event)
   .then(getpointGraphicP);
}

function getpointGraphicP(response) {
   if (response.results.length) {
      var graphicP = response.results.filter(function (result) {
      return result.graphic === pointGraphicP;
      })[0].graphic;
      if (graphicP.id == 71) {
         alert(graphicP.id);
      }
   }
}

but it does not work.
I am using version 4.7 of the ArcGis api.

Outcomes