-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "draggable" property to "Marker" class #3087
Comments
This is an extremely important feature for us to convert from Google as our users readjust markers frequently. |
we have an example illustrating how to do this, but it would indeed be nice to just bundle this into a |
Thanks Peter. I saw an example that used d3.js to manage the drag and drop. In our application we are already using Kendo UI so I decided to use that and appears to work fine.
Still would be nice to have this native on the marker class though.
Michael
…________________________________
From: Peter Liu <notifications@github.com>
Sent: Wednesday, April 5, 2017 4:03 PM
To: mapbox/mapbox-gl-js
Cc: keyofj; Comment
Subject: Re: [mapbox/mapbox-gl-js] Add "draggable" property to "Marker" class (#3087)
we have an example illustrating how to do this<https://www.mapbox.com/mapbox-gl-js/example/drag-a-point/>, but it would indeed be nice to just bundle this into a draggable parameter when instantiating the marker.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#3087 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AHoyQFKMGAzFKn52zVfTCQeRCTkjiPDFks5rs_OEgaJpZM4Ju9_W>.
|
To improve performance of the current (non-marker) implementation for sources/layers with a lot of data we use a custom solution that goes like this:
Of course this adds a fair bit of complexity and we've not managed to account for some edge cases. The majority of the time a "draggable marker" alternative would be more than sufficient. |
How about it like this? |
Hi @EgaK Thanks for the demo! It works well and if that meets your needs, definitely feel free to use it. Draggable markers of the |
@ryanhamley |
How to enable the Draggable capability of Marker with the latest release (0.45.0) ? is draggable an option of the Marker or a function to call? do you have a cope snippet ? |
Hi @hduchesn Draggable markers were added after 0.45.0 was released so they are not available in that version. If you would like to use them now, you can target the The next release includes a draggable marker example, but they can be implemented with a simple option to the Marker constructor.
|
Hi, I updated my mapbox version to 0.48.0 and am using the setDraggable on a marker. The issue is that once I add setDraggable and I bind the drag event to it the event doesn't work. how can I listen to the dragging of the marker and get its new coordinate? thanks |
You can use the |
Thanks for the quick reply, it is working now! |
The draggable marker is working. However I am saving the new coordinates to the server after every drag, and sometimes while trying to drag get errors: mapbox-gl.js:33 Uncaught TypeError: Cannot read property 'unproject' of undefined mapbox-gl.js:29 Uncaught TypeError: Cannot read property 'x' of null And then the marker becomes un-draggable. |
@Rebeccau is there a consistent way to reproduce this? a particular action or sequence of actions that causes it? it sounds like a possible race condition |
Hi Guys, is there a way to have mousemove and mouseleave event in the maker with draggable = true as we do with dragend and dragStart? this.marker = new mapboxgl.Marker({ element: markerdiv, draggable: true }) |
mapbox-gl-js version:Master
Steps to Trigger Behavior
It would be really nice if there were a draggable property on ui/marker.js. Would make it easy porting over web apps reliant on G Maps. Adding a geojson source and using setData every time a move event is emitted for modeling dragging is unacceptably slow. It looks like Geojsonsources aren't able to handle data that changes as frequently as the mouse move event.
Markers that are regular html divs would likely be more performant (for a small number of them) since they can just translate the position themselves upon dragging.
Here is the specific property I am referring to.
https://developers.google.com/maps/documentation/javascript/markers#draggable
Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: