Marker Drag and drop event with overlay image calculate pix issue

282 Views Asked by At

this is an example. I am creating a custom function GetCoordinates this function calculates x and y positions for the image. but this function is not working for your Mapbox init method. can you help me with what can I do this?. Example: "https://jsfiddle.net/ufnvepms/"

1

There are 1 best solutions below

0
On

Are you trying to get the coordinates of the marker as it is dragged? Or do you want to get the corresponding x/y position of the source image?

The first can be done by adding a listener on the "dragend" event, to get the lat/lon of the marker, as in this example: https://docs.mapbox.com/mapbox-gl-js/example/drag-a-marker/

If you need the second, it would require some more calculation, but before figuring that out wanted to understand more precisely what you're trying to achieve.