Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter] Implement google maps flutter heatmap #2454

Conversation

SvenSlijkoord
Copy link

@SvenSlijkoord SvenSlijkoord commented Jan 8, 2020

Description

Implements heatmap support for the google_maps_flutter package.

Related Issues

flutter/flutter#33586

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@SvenSlijkoord SvenSlijkoord changed the title Implement google maps flutter heatmap [google_maps_flutter] Implement google maps flutter heatmap Jan 11, 2020
@urmilshroff
Copy link

Thank you for this! Let's hope it gets merged soon 🙏

Copy link
Contributor

@cyanglaz cyanglaz left a 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?

import com.google.maps.android.heatmaps.WeightedLatLng;
import java.util.List;

class HeatmapBuilder implements HeatmapOptionsSink {
Copy link
Contributor

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;
Copy link
Contributor

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() {
Copy link
Contributor

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.

Comment on lines 60 to 62
NSNumber* latitude = data[i][0][0];
NSNumber* longitude = data[i][0][1];
NSNumber* intensity = data[i][1];
Copy link
Contributor

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]

Copy link
Author

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?

Comment on lines 74 to 81
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;
Copy link
Contributor

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.

Copy link
Author

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.

Comment on lines 84 to 92
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;
}
Copy link
Contributor

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.

Copy link
Author

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.

@cyanglaz
Copy link
Contributor

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?

@SvenSlijkoord
Copy link
Author

@cyanglaz let me look into it.

@Alystrasz
Copy link

Are there any updates on this PR? Are CI-reported issues hard to fix?
Heatmaps feature is part of the flutter todo list and is long-awaited by devs (flutter/flutter#33586).

@bmabir17
Copy link

bmabir17 commented Apr 20, 2020

Are there any updates on this PR? Are CI-reported issues hard to fix?
Heatmaps feature is part of the flutter todo list and is long-awaited by devs (flutter/flutter#33586).

@Alystrasz
I urgently needed this feature so i have forked this pull request
And published a forked package google_maps_flutter_heatmap (Tested only on android)

@SvenSlijkoord Thank you so much!! Hope you won't mind,that i published it on pub.

@Alystrasz
Copy link

@bmabir17
Actually, I'm using your fork right now in my project (thanks btw), but I need iOS support as well 😃

@bmabir17
Copy link

bmabir17 commented Apr 20, 2020

@bmabir17
Actually, I'm using your fork right now in my project (thanks btw), but I need iOS support as well 😃

Can you tell me what's the error that you are facing for ios? Don't have an ios device to debug it 🙁

Copy link
Member

@ditman ditman left a 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!

packages/google_maps_flutter/lib/src/controller.dart Outdated Show resolved Hide resolved
packages/google_maps_flutter/lib/src/heatmap.dart Outdated Show resolved Hide resolved
packages/google_maps_flutter/lib/src/heatmap_updates.dart Outdated Show resolved Hide resolved
@YazeedAlKhalaf
Copy link

Guys, When will this be merged?

@ditman
Copy link
Member

ditman commented Apr 24, 2020

The refactor has landed.

@Alystrasz
Copy link

@SvenSlijkoord do you plan to refactor your PR according to the recent plugins refactor ?

@SvenSlijkoord
Copy link
Author

SvenSlijkoord commented Apr 28, 2020 via email

@iskakaushik iskakaushik removed their request for review April 28, 2020 16:38
@stuartmorgan
Copy link
Contributor

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.

@stuartmorgan
Copy link
Contributor

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.

fergusdixon added a commit to fergusdixon/plugins that referenced this pull request Dec 15, 2021
fergusdixon added a commit to fergusdixon/plugins that referenced this pull request Dec 20, 2021
@godofredoc godofredoc changed the base branch from master to main January 6, 2022 22:14
fergusdixon added a commit to fergusdixon/plugins that referenced this pull request Jan 8, 2022
@stuartmorgan
Copy link
Contributor

stuartmorgan commented Feb 8, 2022

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.

@ditman
Copy link
Member

ditman commented Feb 9, 2022

Status update from PR triage: #3062 is still going through review.

@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.

@stuartmorgan
Copy link
Contributor

That makes sense. @SvenSlijkoord Are you still interested in updating this PR to the current state of the plugin?

@stuartmorgan
Copy link
Contributor

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
9 participants