Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add First-Class Support For Listening to onCameraIdle events #280

Merged
merged 2 commits into from
May 24, 2020

Conversation

nicholasray
Copy link
Contributor

@nicholasray nicholasray commented May 23, 2020

I believe the use case for the onCameraIdle event [1] is large enough
that this event should be able to be listened to directly without having
to listen to extraneous events via the ChangeNotifier interface. The
extraneous events which I think add too much noise when combined with
the camera idle event include:

  • Camera Start/Move Events
  • Updating Map Options
  • Adding/Updating/Removing/Clearing a Symbol, Line, or Circle

For example, the use case described in #131 where a client wants to
display symbols within a bounding box after a user pans the map should
be able to have first-class support. FWIW, other flutter mapping plugins
provide this ability, and it is very useful [2].

Usage:

MapboxMap(
  onCameraIdle: () {
    print("Camera has idled.");
  },
);

[1] https://github.com/tobrun/flutter-mapbox-gl/blob/1bbe7ea7adc8030af16a3cdbf5ade2f94ddea6bd/lib/src/controller.dart#L156
[2] https://github.com/flutter/plugins/blob/61775d32f1d1f0997e0e93bb1e8676b96be9d848/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart#L136

I believe the use case for the `onCameraIdle` event [1] is large enough
that this event should be able to be listened to directly without having
to listen to extraneous events via the ChangeNotifier interface. The
extraneous events which I think add too much noise when combined with
the camera idle event include:

* Camera Start/Move Events
* Updating Map Options
* Adding/Updating/Removing/Clearing a Symbol, Line, or Circle

For example, the use case described in flutter-mapbox-gl#131 where a client wants to
display symbols within a bounding box after a user pans the map should
be able to have first-class support. FWIW, other flutter mapping plugins
provide this ability, and it is very useful [2].

Usage:

```
MapboxMap(
  onCameraIdle: () {
    print("Camera has idled.");
  },
);
```

[1] https://github.com/tobrun/flutter-mapbox-gl/blob/1bbe7ea7adc8030af16a3cdbf5ade2f94ddea6bd/lib/src/controller.dart#L156
[2] https://github.com/flutter/plugins/blob/61775d32f1d1f0997e0e93bb1e8676b96be9d848/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart#L136
@nicholasray nicholasray force-pushed the add-on-camera-idle branch from 95bbe90 to c6e61e8 Compare May 23, 2020 16:24
Copy link
Collaborator

@m0nac0 m0nac0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicholasray Thank you for the contribution, looks great! If you don't mind, I took the liberty and added a simple one-line example in move_camera.dart, this enables others to see all the plugin's features and makes manual testing easier. Otherwise feel free to revert it, of course.

@m0nac0 m0nac0 added the enhancement New feature or request label May 24, 2020
@nicholasray
Copy link
Contributor Author

@m0nac0 Thank you, looks good to me!

@m0nac0
Copy link
Collaborator

m0nac0 commented May 24, 2020

@nicholasray Great, feel free to merge then.

@nicholasray
Copy link
Contributor Author

I don't have write access to merge this PR, but welcome anyone who does :)

@m0nac0
Copy link
Collaborator

m0nac0 commented May 24, 2020

@nicholasray Sorry, I thought you'd be able to merge it after I approved it.

@m0nac0 m0nac0 merged commit 5fa54d4 into flutter-mapbox-gl:master May 24, 2020
@nicholasray
Copy link
Contributor Author

No worries, thank you!

@nicholasray nicholasray deleted the add-on-camera-idle branch May 24, 2020 20:40
andrea689 added a commit to andrea689/flutter-mapbox-gl that referenced this pull request Jun 3, 2020
* master:
  [flutter] release v0.6.0
  Change gradle version to 3.5.0 instead of 3.6.1
  Update Mapbox plugins and gradle
  iOS: add long press handler (flutter-mapbox-gl#268)
  [android] Implemented long click for Android (flutter-mapbox-gl#198)
  [fix] Change default MyLocationTrackingMode to None (flutter-mapbox-gl#285)
  Add First-Class Support For Listening to `onCameraIdle` events (flutter-mapbox-gl#280)
  CI: use stable flutter channel also on iOS (flutter-mapbox-gl#270)
  Implement addImage() to style (flutter-mapbox-gl#269)
  Add animation duration for animateCamera (flutter-mapbox-gl#259)
  Document onStyleLoadedCallback (flutter-mapbox-gl#257)
  example: rename Page to ExamplePage (flutter-mapbox-gl#258)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants