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

Batch create, batch delete for symbols #279

Merged
merged 4 commits into from
Jun 9, 2020

Conversation

Lobankovanastia
Copy link
Contributor

I have many markers on the map and it was visible how do they appear one after another, so I implemented batch create and batch remove for symbols. I would be happy to contribute.
See:
single: single create
batch: batch create

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.

@Lobankovanastia Thank you for this PR, this is a very useful feature and has already been requested in the past! (#210)
I just left a suggestion on how we might be able to simplify the Android code a little bit, I basically just pasted your code together to reduce the number of new classes ;)
(I personally feel like it would be nicer to have a slightly more complex MapboxMapController at the benefit of less additional classes, but that's just my two cents, and others might think differently about it.)
Let me know what you think about it.

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

Lobankovanastia commented May 30, 2020

Thank you for feedback @m0nac0, @TimothySealy ! I applied requested changes. I would also prefer to keep only symbol#add with functionality of addAll, symbol#remove with functionality of removeAll on android side and on Dart side keep the current interface(addSymbol, addSymbols) and for adding one symbol transmit array with one element. Would you approve?

@m0nac0
Copy link
Collaborator

m0nac0 commented May 31, 2020

@Lobankovanastia Great work!
I think your second suggestion is reasonable as long as it doesn't impact performance. I added a hacky "performance test" button to the symbols example page with the following code:

FlatButton(
  child: const Text('performance test'),
  onPressed: () {
    final stopwatch = Stopwatch()..start();
    controller.addSymbol(
      SymbolOptions(
          geometry: LatLng(-33.852, 151.211),
          iconImage: "airport-15"),
    );
    stopwatch.stop();
    print(
        'adding single symbol executed in ${stopwatch.elapsed}');
    final stopwatch2 = Stopwatch()..start();
    controller.addSymbols([
      SymbolOptions(
          geometry: LatLng(-33.852, 151.211),
          iconImage: "airport-15")
    ]);
    stopwatch2.stop();
    print(
        'adding list with one element executed in ${stopwatch2.elapsed}');
  },
),

On Android, this gives me negligible differences of below one millisecond, which is totally ok. I guess it'll be similar for iOS, but I haven't been able to run the performance test on iOS. (If you want to make sure, you could also run the above test on iOS yourself)
So feel free to go ahead with that change as well!

@Lobankovanastia
Copy link
Contributor Author

Lobankovanastia commented Jun 1, 2020

@m0nac0, on ios test gives similar results:
flutter: adding single symbol executed in 0:00:00.003253
flutter: adding List with one element executed in 0:00:00.000646
flutter: adding single symbol executed in 0:00:00.000689
flutter: adding list with one element executed in 0:00:00.000575
flutter: adding single symbol executed in 0:00:00.008279
flutter: adding list with one element executed in 0:00:00.001663

I tested the example app, it works as expected on both platforms. Please take a look at the final code.

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.

@Lobankovanastia I just left two more small suggestions, everything else is looking good! Also thank you for running the performance test.

@@ -548,15 +541,6 @@ public void onError(@NonNull String message) {
break;
}
case "symbol#add": {
Copy link
Collaborator

@m0nac0 m0nac0 Jun 2, 2020

Choose a reason for hiding this comment

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

Suggested change
case "symbol#add": {
case "symbols#addAll": {

Could we please keep the "symbol#addAll" or possibly even better: "symbols#addAll"?
This also makes it clear that adding symbols is currently implemented differently than adding circles and lines (which we might want to update at a later time to support batch editing, as well).
Sorry for not thinking about this earlier.

@@ -228,14 +228,7 @@ private CameraPosition getCameraPosition() {
}

private SymbolBuilder newSymbolBuilder() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this isn't really doing anything relevant anymore, couldn't we just replace its usage(s) with new SymbolBuilder()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Sorry for delay. I have updated PR.

Copy link
Collaborator

@tobrun tobrun left a comment

Choose a reason for hiding this comment

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

This is great @Lobankovanastia! would you be able to rebase on top of head of master? With introduction of web support we now have a slightly different codestructure.

@tobrun tobrun added this to the v0.8.0 milestone Jun 6, 2020
@Lobankovanastia Lobankovanastia force-pushed the batch_actions branch 2 times, most recently from 647e2ac to 00929b8 Compare June 9, 2020 15:14
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.

Great work!
Side note: on Android I'm now sometimes seeing newly added symbols appear, disappear again for a very short time and then appear permanently, so they're blinking once just after they're added. This is very subtle though and not a blocker. Just wanted to mention it in case you happened to now the reason.

@Lobankovanastia
Copy link
Contributor Author

@m0nac0, thank you for approval! Regarding the issue, I have also seen that, but I checked the master branch - same there

@m0nac0
Copy link
Collaborator

m0nac0 commented Jun 9, 2020

@Lobankovanastia Good to know it's not related to this PR then, probably just a coincidence that I noticed it today.

@m0nac0 m0nac0 merged commit 9a1a835 into flutter-mapbox-gl:master Jun 9, 2020
@Lobankovanastia
Copy link
Contributor Author

I created an issue with blinking

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.

4 participants