You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
A workaround would at least be to provide a MapView.OnMoveListener with a onMove callback. The callback would typically be called if the view detecs a MotionEvent.ACTION_MOVE event and the event is not dispatched as a scroll event. This happens e.g. after a long-press followed by a drag.
We are currently working on an Android Map Editor using mapbox-gl-native as the framework. However, I see no possibilities for detecting when the user tries to move a marker. With the above workaround we could detect a long-press followed by a move event and then move the marker by recreating it in the new position.
@ljbade Thanks for the advice. I was actually in the middle of preparing a pull request for a full-blown implementation of the OnMarkerDragListener API, but might try this workaround instead.
Of course, if there are future plans for a Mapbox "drag marker" API, I would be happy to continue working on it.
Hi @tobrun ,
could you please elaborate how you would realize draggable markers with marker views? (I was looking for a possibility to add a touch listener to a marker view but could not find any.)
I'm also interested how to drag Markers same way as it is possible in Google Maps. @tobrun please give us some suggestions or code snippet how you thought to implement it using View Markers.
What are the development plans in this area?
@p-fischer@filipc at this point I haven't started to think about the actual implementation or haven't discussed this internally. This feature just barely didn't make the cut for the 4.1.0 feature list and was considered a nice to have. @frederoni is working on the iOS equivalent in #5373.
Ideally I would love to support the multi window drag/drop functionality as shown at Google I/O this year. This will require us to use the Android SDK drag and drop and not create something custom from scratch. At this point, when a drag starts we probably need to call removeMarker and re-add it again when we drop the marker.
Android : any update or trick we use drag marker or point or polyline on map???
i am stuck for four three days on drag marker or point on polyline???
kindly help me to solve out this problem or code??
@vanshg thansk for quick reply i implement but here map.getSelectedMarkers(); and screenDensity cannot resolve??map not resolve
annotation.setPosition(map.
this also
@Meerz You will need to adjust the code I posted to match what you've named your variables. In this case, map refers to the MapboxMap instance. You can set screenDensity equal to getResources().getDisplayMetrics().density;
Also, I believe I spoke too soon. The code I posted earlier may need a couple other modifications to work. You should be able to get rid of reflection and get rid of the try-catch (replace the reflection code with List<MarkerView> nearbyMarkers = map.getMarkerViewsInRect(tapRect);
Activity
pshustad commentedon Nov 6, 2015
A workaround would at least be to provide a
MapView.OnMoveListenerwith aonMovecallback. The callback would typically be called if the view detecs aMotionEvent.ACTION_MOVEevent and the event is not dispatched as a scroll event. This happens e.g. after a long-press followed by a drag.We are currently working on an Android Map Editor using mapbox-gl-native as the framework. However, I see no possibilities for detecting when the user tries to move a marker. With the above workaround we could detect a long-press followed by a move event and then move the marker by recreating it in the new position.
mapbox#2450 : add draggable property to Marker
mapbox#2450 : add draggable property to Marker
Add Draggable Markers mapbox#2450
Add Draggable Markers mapbox#2450, removed experimental commented-out…
[android] Make Annotation.getId() suitable for public use.
ljbade commentedon Nov 9, 2015
@pshustad It is possible to add your own
onTouchlistener toMapViewfrom an activity since it inherits that fromView.We used this as a work around to detect long presses until we had a chance to add a long press listener.
pshustad commentedon Nov 10, 2015
@ljbade Thanks for the advice. I was actually in the middle of preparing a pull request for a full-blown implementation of the
OnMarkerDragListenerAPI, but might try this workaround instead.Of course, if there are future plans for a Mapbox "drag marker" API, I would be happy to continue working on it.
ljbade commentedon Nov 10, 2015
@pshustad feel free to keep working on a PR if you want. I just wanted to let you know about the work around.
tobrun commentedon May 20, 2016
Now that #3276 has landed this feature can be implemented using View Markers instead of GL Markers
p-fischer commentedon Jun 9, 2016
Hi @tobrun ,
could you please elaborate how you would realize draggable markers with marker views? (I was looking for a possibility to add a touch listener to a marker view but could not find any.)
filipc commentedon Jun 23, 2016
I'm also interested how to drag Markers same way as it is possible in Google Maps.
@tobrun please give us some suggestions or code snippet how you thought to implement it using View Markers.
What are the development plans in this area?
tobrun commentedon Jun 23, 2016
@p-fischer @filipc at this point I haven't started to think about the actual implementation or haven't discussed this internally. This feature just barely didn't make the cut for the
4.1.0feature list and was considered a nice to have. @frederoni is working on the iOS equivalent in #5373.Ideally I would love to support the multi window drag/drop functionality as shown at Google I/O this year. This will require us to use the Android SDK drag and drop and not create something custom from scratch. At this point, when a drag starts we probably need to call
removeMarkerand re-add it again when we drop the marker.DavidMont commentedon Jul 15, 2016
I hope this will become sooner, My legacy mapbox android have draggable marker, I dont want to change/remove it from this current mapbox sdk
11 remaining items
MapboxMapFragment: Move map to place user marker
codebee commentedon Mar 19, 2018
Hi, Any update on for the draggable marker feature? Thanks :)
Meerz commentedon Apr 20, 2018
Android : any update or trick we use drag marker or point or polyline on map???
i am stuck for four three days on drag marker or point on polyline???
kindly help me to solve out this problem or code??
vanshg commentedon Apr 20, 2018
@Meerz Refer to the code I posted a few comments above. I can confirm it is still working on Mapbox 6.0.1
@tobrun Is this feature in any future roadmap?
Meerz commentedon Apr 20, 2018
@vanshg thansk for quick reply i implement but here map.getSelectedMarkers(); and screenDensity cannot resolve??map not resolve
annotation.setPosition(map.
this also
vanshg commentedon Apr 20, 2018
@Meerz You will need to adjust the code I posted to match what you've named your variables. In this case,
maprefers to theMapboxMapinstance. You can setscreenDensityequal togetResources().getDisplayMetrics().density;Also, I believe I spoke too soon. The code I posted earlier may need a couple other modifications to work. You should be able to get rid of reflection and get rid of the
try-catch(replace the reflection code withList<MarkerView> nearbyMarkers = map.getMarkerViewsInRect(tapRect);tobrun commentedon Apr 23, 2018
@vanshg yes, this is going to be implemented when we revamp the annotations api.
atul-anand commentedon Apr 30, 2018
@tobrun Have you decided on the tentative release date after revamping the annotation api?
Meerz commentedon May 18, 2018
@tobrun any upadates regarding draggable marker???
[mapbox#2450] Added draggable markers
tobrun commentedon Jul 6, 2018
An example how to do this with SymbolLayer in #12326
[mapbox#2450] Removed Projection#toScreenLocation call and other chan…
LukasPaczos commentedon Nov 9, 2018
Draggable markers, and annotations in general, support has been added to the Annotation Plugin in the
v0.3.0, see mapbox/mapbox-plugins-android#753.Feel free to check out the plugin and let us know what you think, thanks!
/cc @chloekraw
tobrun commentedon Jan 4, 2019
Annotations are deprecated and are replaced by the annotations plugin. Support for dragging annotations is already implemented.