mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
478 stars 134 forks source link

[Compose] Add `onDrag` support for all annotations #2460

Closed k3nda closed 1 month ago

k3nda commented 3 months ago

New Feature

Add possibility to listen to drag events for all annotations. Either parameter dragListener or all onDragStarted, onDrag and onDragFinished.

Same functionality as it is now possible in non-composable:

    mapView.annotations.createCircleAnnotationManager().apply {
        addDragListener(object : OnCircleAnnotationDragListener {
            override fun onAnnotationDrag(annotation: Annotation<*>) {

            }

            override fun onAnnotationDragFinished(annotation: Annotation<*>) {

            }

            override fun onAnnotationDragStarted(annotation: Annotation<*>) {

            }
        })
    }

Example of usage:

            CircleAnnotationGroup(
                onDragStart = { annotation: CircleAnnotation -> /* handle event */ }
            )

Why

There is onClick parameter already so why there is no support for drag events? It is crucial thing for us as we draw polygons and we need to edit them and move with points.

flasher297 commented 3 months ago

Thank you for the suggestion. We created a ticket to support onDrag in Compose. I'll come back as soon as it's released.

k3nda commented 1 month ago

Can you provide any time estimation of the release please?

kiryldz commented 1 month ago

Can you provide any time estimation of the release please?

Optimistically in v11.8.0-beta.1 coming out next week.

flasher297 commented 1 month ago

@k3nda 11.8.0-beta.1 release is out and it supports draggable annotations in the Compose. You could also check the compose examples in the repo to see how it works. https://github.com/mapbox/mapbox-maps-android/releases/tag/v11.8.0-beta.1