How to apply events on array of Source Component in React Mapbox?
How to apply events on array of Source Component in React Mapbox?
Rendering Source Component imported from React Mapbox.
How to apply events on a single Source like onClick, mouseenter, mouseover etc.
import ReactMapboxGl,
Layer,
Source
from "react-mapbox-gl";
sourceArray.length > 0 && sourceArray.map((item, index) =>
return ( <
Source key =
Math.random()
id =
`source_id$index`
tileJsonSource =
"type": "image",
"url": item.urlAd,
"coordinates": [
[item.boundLtln[3], item.boundLtln[0]],
[item.boundLtln[3], item.boundLtln[2]],
[item.boundLtln[1], item.boundLtln[2]],
[item.boundLtln[1], item.boundLtln[0]]
]
/>
)
)
AddEventListener
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Read about
AddEventListener
– sagi
Sep 3 at 7:02