-
Notifications
You must be signed in to change notification settings - Fork 9.9k
[google_maps_flutter] Implement google maps flutter heatmap #2454
[google_maps_flutter] Implement google maps flutter heatmap #2454
Conversation
Thank you for this! Let's hope it gets merged soon 🙏 |
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.
Thank you for providing this PR. It looks great! Since it is a huge PR, I am not able to run through everything in one pass. I left some comments after a quick scan.
It also seems there are a lot of boiler plates in the Android implementation. Do you think you can refactor it to make the code a bit simpler? For example, I think we can remove some of the HeatmapOptionsSink
implementations to make the code easier to read and maintain. I might be missing something though. WDYT?
packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Outdated
Show resolved
Hide resolved
packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java
Outdated
Show resolved
Hide resolved
import com.google.maps.android.heatmaps.WeightedLatLng; | ||
import java.util.List; | ||
|
||
class HeatmapBuilder implements HeatmapOptionsSink { |
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.
I can see that it might be valuable to factor out everything related to the construction of the HeatmapOptions
.
It doesn't seem to be necessary in this plugin. I would suggest to keep it simple to just create the HeatmapOptions
object directly when it is required (which is only in a single place in this PR).
But I might be missing something?
|
||
private final TileOverlay mTileOverlay; | ||
|
||
private final String mGoogleMapsHeatmapId; |
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.
seems not necessary to cache this in a private variable as it is only used in one place.
|
||
private TileOverlay mTileOverlay; | ||
|
||
public HeatmapOptions() { |
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.
I feel like all these methods should be package scoped instead of public.
packages/google_maps_flutter/example/ios/Flutter/Flutter.podspec
Outdated
Show resolved
Hide resolved
NSNumber* latitude = data[i][0][0]; | ||
NSNumber* longitude = data[i][0][1]; | ||
NSNumber* intensity = data[i][1]; |
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.
will any of these lines crash? For example, will data[i].length < 2
and thus crashes data[i][1]
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.
That would most definitely crash, but that would also mean that the flutter part of this package is implemented improperly.
Should we throw an exception when the data is not correct, or how can this ideally be resolved?
static NSArray<UIColor*>* ToColors(NSArray* data) { | ||
NSMutableArray* colors = [[NSMutableArray alloc] init]; | ||
for (unsigned i = 0; i < [data count]; i++) { | ||
UIColor* color = data[i]; | ||
[colors addObject:color]; | ||
} | ||
|
||
return colors; |
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.
The method seems unnecessary. It doesn't seem to be doing anything with the data in the array. The method just did a deep copy from data
to the return value.
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 method converts a JSON object (NSArray* data) to an array of UIColor*. I am no iOS developer but it didn't seem to work without this method.
static NSArray<NSNumber*>* ToStartsPoints(NSArray* data) { | ||
NSMutableArray* startPoints = [[NSMutableArray alloc] init]; | ||
for (unsigned i = 0; i < [data count]; i++) { | ||
NSNumber* startPoint = data[i]; | ||
[startPoints addObject:startPoint]; | ||
} | ||
|
||
return startPoints; | ||
} |
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.
The method seems unnecessary. The method seems unnecessary. It doesn't seem to be doing anything with the data in the array. The method just did a deep copy from data
to the return value.
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 method converts a JSON object (NSArray* data) to a array of NSNumber*. I am no iOS developer but it didn't seem to work without this method.
I think it might be a good idea to separate tileoverlay and heatmap into 2 different PRs. This will help the PRs to be reviewed faster. #2077 seems trying to add tile overlay for the plugin on Android. @SvenSlijkoord Do you think you can work with the author to put up a PR for tile overlay only? And then a separate PR for heat map? |
@cyanglaz let me look into it. |
Are there any updates on this PR? Are CI-reported issues hard to fix? |
@Alystrasz @SvenSlijkoord Thank you so much!! Hope you won't mind,that i published it on pub. |
@bmabir17 |
Can you tell me what's the error that you are facing for ios? Don't have an ios device to debug it 🙁 |
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.
Hello there! Thank you very much for the PR!
We're about to merge a change to google_maps_flutter, so it follows the "federated implementation" style. This will allow new platforms (like web) to be supported.
Once that change lands, some of the code that you've created/touched should live in the google_maps_flutter_platform_interface
package, and not here.
Check out this PR on how we migrated the whole plugin to the new architecture. It should give you clues on how to modify your code to conform to it.
Feel free to reach out to me if you need any assistance with this!
Guys, When will this be merged? |
The refactor has landed. |
@SvenSlijkoord do you plan to refactor your PR according to the recent plugins refactor ? |
Yes, I will
…On Mon, 27 Apr 2020, 12:19 am Rémy Raes, ***@***.***> wrote:
@SvenSlijkoord <https://github.com/SvenSlijkoord> do you plan to refactor
your PR according to the recent plugins refactor ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2454 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACW2NJNSA3K3BICKLGJL753ROSXOHANCNFSM4KEOBTBQ>
.
|
…ement_google_maps_flutter_heatmap
Once the migration of maps to null-safety is complete, we can move forward with #3062, which takes on just the interface portion of this task, and then hopefully this can be updated to have a narrower scope, and we can get it reviewed. |
We're starting the process of reviewing #3062. While that's happening, this could be updated in parallel to add tests (integration tests, unit tests for the native code) so that it will be closer to being review-ready once that PR is complete and landed. |
Status update from PR triage: #3062 is still going through review. However, this still needs tests before it could move forward even once that PR has landed. |
@stuartmorgan The platform_interface on #3062 has diverged so much from the one here, that IMO we need to bring this PR up to date with the latest code there, and see how it works. |
That makes sense. @SvenSlijkoord Are you still interested in updating this PR to the current state of the plugin? |
Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to submit a new PR if you have the time to address the review comments. Thanks! |
Description
Implements heatmap support for the google_maps_flutter package.
Related Issues
flutter/flutter#33586
Checklist
///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?