Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/gestures/map_interactive_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,10 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
}

void _onPointerMove(PointerMoveEvent event) {
if (_options.onPointerMove != null) {
final latLng = _camera.offsetToCrs(event.localPosition);
_options.onPointerMove!(event, latLng);
}
if (!_ckrTriggered.value) return;

final baseSetNorth =
Expand Down
12 changes: 12 additions & 0 deletions lib/src/map/options/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ typedef PointerHoverCallback = void Function(
LatLng point,
);

/// Callback to notify when the map registers a pointer move event.
typedef PointerMoveCallback = void Function(
PointerMoveEvent event,
LatLng point,
);

/// Callback that gets called when the viewport of the map changes.
///
/// {@macro map_position.has_gesture}
Expand Down Expand Up @@ -109,6 +115,11 @@ class MapOptions {
/// down (e.g. mouse pointers, but not most touch pointers)
final PointerHoverCallback? onPointerHover;

/// Called when a pointer is down and moves.
/// If used while dragging the map, this should return the same location, but it might not due to map pixel snapping.
/// It is more useful to obtain pointer position while map camera position is not changing.
final PointerMoveCallback? onPointerMove;

/// This callback fires when the [MapCamera] data has changed. This gets
/// called if the zoom level, or map center changes.
final PositionCallback? onPositionChanged;
Expand Down Expand Up @@ -158,6 +169,7 @@ class MapOptions {
this.onPointerUp,
this.onPointerCancel,
this.onPointerHover,
this.onPointerMove,
this.onPositionChanged,
this.onMapEvent,
this.onMapReady,
Expand Down