-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
When calling CircleAnnotationManager.create() or CircleAnnotationManager.update() inside dragEnvets' onBegin or onChanged event handler, the following onChanged and onEnd events are never triggered.
This issue is similar to #1026 but the problem occurs inside the event handler.
Environment:
Flutter version: 3.32.0
mapbox_maps_flutter version: 2.17.0
Platform: iOS
Steps to Reproduce:
- Create a CircleAnnotationManager
- Set dragEvents on the CircleAnnotationManager. Inside onBegin event handler, update CircleAnnotation using the manager.
- Create a CircleAnnotation using the CircleAnnotationManager
- Long press the CircleAnnotation and start drag
- The CircleAnnotation never moves
final _dragAnnotationManager = await _mapboxMap.annotations.createCircleAnnotationManager();
// register drag event
_dragAnnotationManager.dragEvents(
onBegin: (annotation) async {
// Change the color when the drag starts
annotation.circleColor = Colors.red.toARGB32();
_dragAnnotationManager.update(annotation);
},
onChanged: (annotation) {
// This code is never called
print('onChanged');
},
onEnd: (annotation) async {
// This code is never called either
print('onEnd');
// Change back the color
annotation.circleColor = Colors.black.toARGB32();
_dragAnnotationManager.update(annotation);
},
);
// create annotation to drag
_dragAnnotationManager.create(
CircleAnnotationOptions(
geometry: Point(
coordinates: Position(coordinate.lng, coordinate.lat),
),
circleRadius: 8.0,
circleColor: Colors.black.toARGB32(),
isDraggable: true,
),
);
Additional context:
I'd like to change the annotation appearance once drag starts. However, updating the annotation inside onBegin clause is not allowed currently.
The only workaround I could take was to
- Create another CircleAnnotationManager
- In side onBegin clause, create another CircleAnnotation to overlay with the desired color
- Update overlay CircleAnnotation's geometry inside onChanged clause
However, the above solution doesn't work perfectly because the overlay annotation can delay when the dragging annotation moves fast.
Metadata
Metadata
Assignees
Labels
No labels