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.

asked Jun 7, 2019 at 15:50

1 Answer 1

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);
});
answered Jun 11, 2019 at 16:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.