I need to make some draggable markers like:
const MyMarkers = () =>
asset.map((item, index) => (
<Marker
key={`marker-${index}`}
longitude={item.lng}
latitude={item.lat}
anchor="bottom"
onClick={e => {
console.log(item);
}}
draggable
onDragEnd={onMarkerDragEnd}
>
<Pin />
</Marker>
));
The problem is, I can't pass a id/value to each marker onMarkerDragEnd function, its parameters are fixed from Docs.
onDragEnd: (evt: MarkerDragEvent) => void
If I do
onDragEnd={onMarkerDragEnd(my_value)}
the function won't work.
I also tried data variable like:
<Marker
...
data-id={item.assetId}
data-value={item.name}
>
This won't work. I can't find the variable using:
const onMarkerDragEnd = useCallback((event: MarkerDragEvent) => {
var a = event.target.dataset; //dataset is undefined
}, []);
Any suggestions?