mstahv / v-leaflet

Leaflet add-on for Vaadin
Other
43 stars 38 forks source link

Feature request: drag and drop #183

Closed sarathas closed 6 years ago

sarathas commented 6 years ago

In my current app, I would like to drag and drop points of interest into an existing LMap (you could say, maybe, restaurants, doors or bins). That is, drag something from outside the map into it and create a marker at the "drop" location. Problem is, I cannot get any data of the current point on the map once the DropEvent is invoked. All there is is the MouseEventDetails telling me about the ClientX/Y and relativeX/Y. But we need the point (lat/lon) on the map.

The org.peimari.gleaflet.client package already has a MouseOverListener. Maybe one could do something with it?

mstahv commented 6 years ago

I just added an API you can use to translate the pixel location to coordinates and an example that uses it. It isn't bulletproof solution (if there happens to be a big latency in communication and user zooms/pans at the same time -> coordinates may be wrong), but it seems to work fairly well.

Let me know if this would work for you. Didn't yet investigate how difficult a perfect solution would be to implement.

sarathas commented 6 years ago

Looks exactly like the thing I was looking for. Thanks a lot!

mstahv commented 6 years ago

This is now available in 2.0.7