2

Currently I can click on the GraphicsLayer and I can see an array of all my Graphics added there.

const layerMarkers = new GraphicsLayer({id: layerId});
this.map.addLayer(layerMarkers);
const graphic = new Graphic(point, imageSymbol, null, null);
layerMarkers.add(graphic);

But how can extract the data from that Graphic and do something with that data? I want to create a InfoTemplate only for that graphic.

layerMarkers.graphics[0].setInfoTemplate(infoTemplate);

I don't wan't to call .graphics[0] that way, I want to pick the array from clickin on the Graphic.

I was trying some this.map.on('click', (evt) => but what I need is to click on a specific Graphic.

1

You should setup a click event listener on the GraphicsLayer. Something like this:

layerMarkers.on('click', function(evt) {
  var graphic = evt.graphic;
  console.log("Clicked graphic:", graphic);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.