-
Notifications
You must be signed in to change notification settings - Fork 509
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
Batch create, batch delete for symbols #279
Conversation
There was a problem hiding this 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.
android/src/main/java/com/mapbox/mapboxgl/SymbolOptionsProvider.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/mapbox/mapboxgl/BatchSymbolsCreateCommand.java
Outdated
Show resolved
Hide resolved
android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
Outdated
Show resolved
Hide resolved
5ac0de1
to
89ead44
Compare
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? |
@Lobankovanastia Great work! 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) |
@m0nac0, on ios test gives similar results: I tested the example app, it works as expected on both platforms. Please take a look at the final code. |
There was a problem hiding this 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": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() { |
There was a problem hiding this comment.
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()
?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
647e2ac
to
00929b8
Compare
00929b8
to
8ef2767
Compare
There was a problem hiding this 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.
@m0nac0, thank you for approval! Regarding the issue, I have also seen that, but I checked the master branch - same there |
@Lobankovanastia Good to know it's not related to this PR then, probably just a coincidence that I noticed it today. |
I created an issue with blinking |
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:
batch: