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

[google_maps_flutter] Add heatmap support #5274

Closed
wants to merge 120 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
f2e9806
Worked on platform interface
Rexios80 Apr 13, 2022
2203401
Added heatmap layer code to web
Rexios80 Apr 14, 2022
bcc8f07
Added web target to example
Rexios80 Apr 14, 2022
b179c93
Worked on interface
Rexios80 Apr 14, 2022
6ee7ae8
Worked on Android implementation
Rexios80 Apr 14, 2022
7f78965
Refactoring
Rexios80 Apr 14, 2022
09c1fab
Android works
Rexios80 Apr 14, 2022
d5d0726
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Apr 14, 2022
cf29213
Java formatting
Rexios80 Apr 14, 2022
b2436f5
Fixed dart analysis
Rexios80 Apr 15, 2022
37c58ad
Added copyright text
Rexios80 Apr 15, 2022
789cd9a
Web tests
Rexios80 Apr 16, 2022
977dfd4
Heatmap updates test
Rexios80 Apr 16, 2022
d27c28c
Gradient works
Rexios80 Apr 17, 2022
2df83b5
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 Apr 18, 2022
efb432a
Example app now launches with Google-Maps-iOS-Utils included
Rexios80 Apr 18, 2022
5703eeb
Worked on ios implementation
Rexios80 Apr 18, 2022
c47d213
iOS kind of works; the gradient is being weird
Rexios80 Apr 19, 2022
2361e47
Merge branch 'flutter:main' into feature/google-maps-heatmap
Rexios80 Apr 19, 2022
72dd326
Merge remote-tracking branch 'origin/feature/google-maps-heatmap' int…
Rexios80 Apr 19, 2022
bc27137
Fixed gradient issue
Rexios80 Apr 19, 2022
146ea54
Only use 0 alpha gradient first color on web
Rexios80 Apr 19, 2022
5ed26a8
Ran clang-format
Rexios80 Apr 19, 2022
bd51355
Ran flutter format
Rexios80 Apr 19, 2022
876998f
iOS heatmap rendering is a lot better
Rexios80 Apr 19, 2022
d4b3524
Formatting
Rexios80 Apr 19, 2022
f6d3050
Merge branch 'flutter:main' into feature/google-maps-heatmap
Rexios80 Apr 26, 2022
8415953
Made WeightedLatLng extend LatLng
Rexios80 Apr 26, 2022
0a9495c
Resolved issues
Rexios80 Apr 26, 2022
65bad90
Fixed web code issue
Rexios80 Apr 26, 2022
319f84e
Resolved issues
Rexios80 Apr 26, 2022
b2e7e5e
Added heatmap controller to umbrella header
Rexios80 Apr 26, 2022
9cb30af
Made min/max zoom intensity configurable from flutter
Rexios80 Apr 26, 2022
5039dd1
Made start points and color map size configurable from flutter
Rexios80 Apr 27, 2022
177def0
dart formatting
Rexios80 Apr 27, 2022
ca94502
Fixed test code
Rexios80 Apr 27, 2022
6ee5fed
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Apr 28, 2022
d341949
Better use of null safety
Rexios80 May 1, 2022
c3e904f
Added web heatmaps tests
Rexios80 May 3, 2022
5cd2524
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 May 3, 2022
7ad6e7b
Fixed web tests
Rexios80 May 3, 2022
7978892
Fixed another web test issue
Rexios80 May 3, 2022
d76e161
Got NSAssert working
Rexios80 May 4, 2022
dd3c82f
Removed incorrect doc comment
Rexios80 May 5, 2022
f89a3f4
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 May 10, 2022
994fd1f
Fixed analysis issues with HeatmapPage in example
Rexios80 May 10, 2022
f96f844
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 May 21, 2022
3c6c7cd
Fixed analysis issues
Rexios80 May 21, 2022
f63af88
Formatting
Rexios80 May 21, 2022
1160e32
Fixed issues
Rexios80 May 21, 2022
c41b00a
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 May 23, 2022
ead58b8
Added license text to example/web/index.html
Rexios80 May 23, 2022
d1a8856
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 May 23, 2022
5c78283
Merge branch 'google_map_clean_up' into feature/google-maps-heatmap
Rexios80 Jun 15, 2022
b9dd462
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Jun 15, 2022
d1daad1
Formatting
Rexios80 Jun 15, 2022
35d8715
Don't know where that came from but okay
Rexios80 Jun 15, 2022
ccc9ca2
iOS example changes
Rexios80 Jun 16, 2022
ea1975b
Added iOS JSON conversion tests
Rexios80 Jun 16, 2022
d39a901
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 Jul 11, 2022
89239ab
Fixed issues
Rexios80 Jul 14, 2022
e5b4943
Refactored heatmap controllers
Rexios80 Jul 14, 2022
3c7d7dc
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 Jul 14, 2022
011828d
Added swift version to podspec for CI
Rexios80 Jul 14, 2022
c39446b
Removed `use_modular_headers!` from Podfile
Rexios80 Jul 15, 2022
4999d14
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Aug 16, 2022
681eae8
Fixed missing things
Rexios80 Aug 16, 2022
0bf8dd2
Fixed issues
Rexios80 Aug 17, 2022
d011011
Xcode project file changes
Rexios80 Aug 17, 2022
b7f4f72
Formatting
Rexios80 Aug 17, 2022
906c3f0
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Aug 17, 2022
09467d1
Reverted changes to other packages
Rexios80 Aug 17, 2022
a5e1e5f
Fixed umbrella header
Rexios80 Aug 17, 2022
686b60a
Formatting
Rexios80 Aug 17, 2022
70c8dbe
Fixed issues
Rexios80 Aug 17, 2022
4eaa5d3
Reverted changes to pbxproj file
Rexios80 Aug 17, 2022
b9d33cd
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 Aug 18, 2022
882d3b4
Merge branch 'main' into feature/google-maps-heatmap
Rexios80 Aug 18, 2022
9005231
Fixes
Rexios80 Sep 1, 2022
0c03dad
Fixes
Rexios80 Sep 1, 2022
6d69bed
Fixes
Rexios80 Sep 1, 2022
edcede1
Fixes
Rexios80 Sep 1, 2022
cd24b9e
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 Sep 7, 2022
e67b408
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Oct 17, 2022
f4d5c86
Fixed build issues
Rexios80 Oct 17, 2022
2f745ab
Fixed web test issues
Rexios80 Oct 17, 2022
1ce1595
Fixed analysis issues
Rexios80 Oct 17, 2022
b2be041
iOS build changes
Rexios80 Oct 18, 2022
60e15ea
Updated example
Rexios80 Oct 19, 2022
612e5be
Updated documentation
Rexios80 Oct 19, 2022
7c22792
Removed assertion for radius value
Rexios80 Oct 19, 2022
1d212eb
Fixed building in google_maps_flutter_ios/example
Rexios80 Oct 19, 2022
f1105ad
Formatting
Rexios80 Oct 19, 2022
ef7a9d4
Fixed android build issue
Rexios80 Oct 21, 2022
8c7c8f0
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 Oct 24, 2022
43ba954
Merge branch 'master' into feature/google-maps-heatmap
Rexios80 Dec 20, 2022
3928a72
Assert that heatmap data is not empty
Rexios80 Jan 1, 2023
4d6392b
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 Jan 12, 2023
5c8839e
Revert "Assert that heatmap data is not empty"
Rexios80 Jan 12, 2023
c187469
Working on testing
Rexios80 Jan 12, 2023
feeed2c
Refactoring
Rexios80 Jan 12, 2023
e7471ea
Wrote some dart code
Rexios80 Jan 12, 2023
e779c77
Working on integration tests
Rexios80 Jan 12, 2023
aab722a
Fixing things
Rexios80 Jan 12, 2023
e08a292
Test passes
Rexios80 Jan 12, 2023
20591b0
Working on test
Rexios80 Jan 12, 2023
5235dad
Added heatmaps update test
Rexios80 Jan 12, 2023
55988cc
Added remove heatmaps test
Rexios80 Jan 12, 2023
e6e1af2
Working on Android tests
Rexios80 Jan 12, 2023
28468b2
Android tests work
Rexios80 Jan 12, 2023
35d12bd
Formatting
Rexios80 Jan 12, 2023
5c8ce27
Uncommented other tests
Rexios80 Jan 12, 2023
597d065
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 Jan 27, 2023
115ed7f
Undoing unnecessary changes to example
Rexios80 Jan 27, 2023
b3e1d4a
Rewrite tests using `moreOrLessEquals`
Rexios80 Jan 27, 2023
38ec627
Fixing issues
Rexios80 Jan 27, 2023
3639957
Updated documentation
Rexios80 Jan 30, 2023
89a0e20
Platform-specific serialization
Rexios80 Jan 30, 2023
88db9ca
...
Rexios80 Jan 30, 2023
34deb7d
Merge remote-tracking branch 'origin/master' into feature/google-maps…
Rexios80 Feb 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.3.0

* Adds support for heatmap layers.
* Updates minimum Flutter version to 3.0.

## 2.2.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,257 @@ void main() {
expect(tileOverlayInfo1, isNull);
},
);

/// Check that two lists of [WeightedLatLng] are more or less equal
void expectHeatmapDataMoreOrLessEquals(
List<WeightedLatLng> data1,
List<WeightedLatLng> data2,
) {
expect(data1.length, data2.length);
for (int i = 0; i < data1.length; i++) {
final WeightedLatLng wll1 = data1[i];
final WeightedLatLng wll2 = data2[i];
expect(wll1.weight, wll2.weight);
expect(wll1.point.latitude, moreOrLessEquals(wll2.point.latitude));
expect(wll1.point.longitude, moreOrLessEquals(wll2.point.longitude));
}
}

/// Check that two [HeatmapGradient]s are more or less equal
void expectHeatmapGradientMoreOrLessEquals(
HeatmapGradient? gradient1,
HeatmapGradient? gradient2,
) {
if (gradient1 == null) {
expect(gradient2, isNull);
return;
}
expect(gradient2, isNotNull);

expect(gradient1.colors.length, gradient2!.colors.length);
for (int i = 0; i < gradient1.colors.length; i++) {
final HeatmapGradientColor color1 = gradient1.colors[i];
final HeatmapGradientColor color2 = gradient2.colors[i];
expect(color1.color, color2.color);
expect(
color1.startPoint,
moreOrLessEquals(color2.startPoint, epsilon: 1e-7),
);
}

expect(gradient1.colorMapSize, gradient2.colorMapSize);
}

void expectHeatmapEquals(Heatmap heatmap1, Heatmap heatmap2) {
expectHeatmapDataMoreOrLessEquals(heatmap1.data, heatmap2.data);
expectHeatmapGradientMoreOrLessEquals(heatmap1.gradient, heatmap2.gradient);
if (Platform.isAndroid) {
expect(heatmap1.maxIntensity, heatmap2.maxIntensity);
}
expect(heatmap1.opacity, moreOrLessEquals(heatmap2.opacity, epsilon: 1e-8));
expect(heatmap1.radius, heatmap2.radius);
if (Platform.isIOS) {
expect(heatmap1.minimumZoomIntensity, heatmap2.minimumZoomIntensity);
expect(heatmap1.maximumZoomIntensity, heatmap2.maximumZoomIntensity);
}
}

final Heatmap heatmap1 = Heatmap(
heatmapId: const HeatmapId('heatmap_1'),
data: const <WeightedLatLng>[
WeightedLatLng(LatLng(37.782, -122.447)),
WeightedLatLng(LatLng(37.782, -122.445)),
WeightedLatLng(LatLng(37.782, -122.443)),
WeightedLatLng(LatLng(37.782, -122.441)),
WeightedLatLng(LatLng(37.782, -122.439)),
WeightedLatLng(LatLng(37.782, -122.437)),
WeightedLatLng(LatLng(37.782, -122.435)),
WeightedLatLng(LatLng(37.785, -122.447)),
WeightedLatLng(LatLng(37.785, -122.445)),
WeightedLatLng(LatLng(37.785, -122.443)),
WeightedLatLng(LatLng(37.785, -122.441)),
WeightedLatLng(LatLng(37.785, -122.439)),
WeightedLatLng(LatLng(37.785, -122.437)),
WeightedLatLng(LatLng(37.785, -122.435), weight: 2)
],
dissipating: false,
gradient: HeatmapGradient(
const <HeatmapGradientColor>[
HeatmapGradientColor(
Color.fromARGB(255, 0, 255, 255),
0.2,
),
HeatmapGradientColor(
Color.fromARGB(255, 0, 63, 255),
0.4,
),
HeatmapGradientColor(
Color.fromARGB(255, 0, 0, 191),
0.6,
),
HeatmapGradientColor(
Color.fromARGB(255, 63, 0, 91),
0.8,
),
HeatmapGradientColor(
Color.fromARGB(255, 255, 0, 0),
1,
),
],
),
maxIntensity: 1,
opacity: 0.5,
radius: 40,
minimumZoomIntensity: 1,
maximumZoomIntensity: 20,
);

testWidgets(
'set heatmap correctly',
(WidgetTester tester) async {
final Completer<int> mapIdCompleter = Completer<int>();
final Heatmap heatmap2 = Heatmap(
heatmapId: const HeatmapId('heatmap_2'),
data: heatmap1.data,
dissipating: heatmap1.dissipating,
gradient: heatmap1.gradient,
maxIntensity: heatmap1.maxIntensity,
opacity: heatmap1.opacity - 0.1,
radius: heatmap1.radius,
minimumZoomIntensity: heatmap1.minimumZoomIntensity,
maximumZoomIntensity: heatmap1.maximumZoomIntensity,
);

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
initialCameraPosition: _kInitialCameraPosition,
heatmaps: <Heatmap>{heatmap1, heatmap2},
onMapCreated: (GoogleMapController controller) {
mapIdCompleter.complete(controller.mapId);
},
),
),
);
await tester.pumpAndSettle(const Duration(seconds: 3));

final int mapId = await mapIdCompleter.future;
final GoogleMapsInspectorPlatform inspector =
GoogleMapsInspectorPlatform.instance!;

final Heatmap heatmapInfo1 =
(await inspector.getHeatmapInfo(heatmap1.mapsId, mapId: mapId))!;
final Heatmap heatmapInfo2 =
(await inspector.getHeatmapInfo(heatmap2.mapsId, mapId: mapId))!;

expectHeatmapEquals(heatmap1, heatmapInfo1);
expectHeatmapEquals(heatmap2, heatmapInfo2);
},
);

testWidgets(
'update heatmaps correctly',
(WidgetTester tester) async {
final Completer<int> mapIdCompleter = Completer<int>();
final Key key = GlobalKey();

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
key: key,
initialCameraPosition: _kInitialCameraPosition,
heatmaps: <Heatmap>{heatmap1},
onMapCreated: (GoogleMapController controller) {
mapIdCompleter.complete(controller.mapId);
},
),
),
);

final int mapId = await mapIdCompleter.future;
final GoogleMapsInspectorPlatform inspector =
GoogleMapsInspectorPlatform.instance!;

final Heatmap heatmap1New = heatmap1.copyWith(
dataParam: heatmap1.data.sublist(5),
dissipatingParam: !heatmap1.dissipating,
gradientParam: heatmap1.gradient,
maxIntensityParam: heatmap1.maxIntensity! + 1,
opacityParam: heatmap1.opacity - 0.1,
radiusParam: heatmap1.radius + 1,
minimumZoomIntensityParam: heatmap1.minimumZoomIntensity + 1,
maximumZoomIntensityParam: heatmap1.maximumZoomIntensity + 1,
);

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
key: key,
initialCameraPosition: _kInitialCameraPosition,
heatmaps: <Heatmap>{heatmap1New},
onMapCreated: (GoogleMapController controller) {
fail('update: OnMapCreated should get called only once.');
},
),
),
);

await tester.pumpAndSettle(const Duration(seconds: 3));

final Heatmap heatmapInfo1 =
(await inspector.getHeatmapInfo(heatmap1.mapsId, mapId: mapId))!;

expectHeatmapEquals(heatmap1New, heatmapInfo1);
},
);

testWidgets(
'remove heatmaps correctly',
(WidgetTester tester) async {
final Completer<int> mapIdCompleter = Completer<int>();
final Key key = GlobalKey();

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
key: key,
initialCameraPosition: _kInitialCameraPosition,
heatmaps: <Heatmap>{heatmap1},
onMapCreated: (GoogleMapController controller) {
mapIdCompleter.complete(controller.mapId);
},
),
),
);

final int mapId = await mapIdCompleter.future;
final GoogleMapsInspectorPlatform inspector =
GoogleMapsInspectorPlatform.instance!;

await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
key: key,
initialCameraPosition: _kInitialCameraPosition,
onMapCreated: (GoogleMapController controller) {
fail('OnMapCreated should get called only once.');
},
),
),
);

await tester.pumpAndSettle(const Duration(seconds: 3));
final Heatmap? heatmapInfo1 =
await inspector.getHeatmapInfo(heatmap1.mapsId, mapId: mapId);

expect(heatmapInfo1, isNull);
},
);
}

class _DebugTileProvider implements TileProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
Loading