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

Listener Called when camera moved / Bounding Box #131

Closed
matyhaty opened this issue Nov 27, 2019 · 1 comment
Closed

Listener Called when camera moved / Bounding Box #131

matyhaty opened this issue Nov 27, 2019 · 1 comment

Comments

@matyhaty
Copy link

Hi all

We are using this plugin to add a lot of points and lines to the map.
So we need to ensure we only draw what is needed (aka the viewport) and when the camera is moved or panned - we update the map with new points and lines within the new viewport.

We dont seem to have:

  • The current viewport (lat/long from top left to bottom right)
  • A method which is called when the camera positioned is moved (and completes movement)

Apologies if we have missed this, but any help would be greatly appreciated.

@m0nac0
Copy link
Collaborator

m0nac0 commented Jan 11, 2020

@matyhaty The new getVisibleRegion() method has landed (for Android) in #152. iOS support is still WIP (see #170) .
MapboxMapController extends ChangeNotifier, so you can listen for changes by calling addListener() on your MapboxMapController and it should notify you when the isCameraMoving property has changed (and also for changes to some other properties). Note: you will also have to initialize your MapboxMap with isCameraMoving=true to get notified for camera movement events.
Will that solve your issues?

@m0nac0 m0nac0 closed this as completed Jan 16, 2020
nicholasray pushed a commit to nicholasray/flutter-mapbox-gl that referenced this issue 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 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.

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 pushed a commit to nicholasray/flutter-mapbox-gl that referenced this issue 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants