flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 503 forks source link

Expose onDrag handler in AnnotationManager. #1182

Closed fmatuszewski closed 1 year ago

fmatuszewski commented 2 years ago

Can we expose onDrag handler in AnnotationManager the same way onTap is exposed

/// Called if a annotation is tapped
  final void Function(T)? onTap;
## The CHANGE
  final void Function(T)? onDrag;
    if (onTap != null) {
      controller.onFeatureTapped.add(_onFeatureTapped);
    }
    controller.onFeatureDrag.add(_onDrag);
  _onFeatureTapped(dynamic id, Point<double> point, LatLng coordinates) {
    final annotation = _idToAnnotation[id];
    if (annotation != null) {
      onTap!(annotation);
    }
  }
  _onDrag(dynamic id,
      {required Point<double> point,
      required LatLng origin,
      required LatLng current,
      required LatLng delta,
      required DragEventType eventType}) {
    final annotation = byId(id);
    if (annotation != null) {
      annotation.translate(delta);
      set(annotation);
## The CHANGE
      onDrag!(annotation);
## The CHANGE
    }
  }
felix-ht commented 2 years ago

yeah no reason why not - feel free to create a pull request

note that it should be

  `if (onDrag != null) onDrag!(annotation);`
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.