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

[google_maps_flutter] Add heatmap support #3257

Merged
merged 143 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
720b573
Transfer changes from flutter/plugins
Rexios80 Feb 22, 2023
82da77c
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Mar 3, 2023
3f05d83
Use tooling to generate overrides
Rexios80 Mar 7, 2023
6704e92
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Mar 7, 2023
351d93b
Revert example android config changes
Rexios80 Mar 7, 2023
7f3379a
Fix analysis issues
Rexios80 Mar 7, 2023
4eebea2
Formatting
Rexios80 Mar 7, 2023
5580083
Add copyright text
Rexios80 Mar 7, 2023
0b4b449
Fix serialization issue
Rexios80 Mar 7, 2023
d4ec76d
Fix build issue
Rexios80 Mar 7, 2023
5577e7e
Add more overrides
Rexios80 Mar 7, 2023
22eada0
Fix android warnings
Rexios80 Mar 7, 2023
43df52c
Make private thing public for testing
Rexios80 Mar 7, 2023
85cd968
Fix the serialization issue in every other file
Rexios80 Mar 8, 2023
100329c
Merge branch 'main' into google-maps-heatmaps
Rexios80 Mar 8, 2023
c926625
Fix another serialization issue
Rexios80 Mar 8, 2023
557d8bc
Merge branch 'main' into google-maps-heatmaps
Rexios80 Apr 24, 2023
a79562e
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Apr 24, 2023
8d7407d
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Jun 28, 2023
a925381
Fixing issues
Rexios80 Jun 28, 2023
4ed0d61
Fixing issues
Rexios80 Jun 28, 2023
392d86a
Remove duplicated changelog line
Rexios80 Jul 14, 2023
63b1b51
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Sep 1, 2023
f3e9d05
Fixing things
Rexios80 Sep 1, 2023
9a8e182
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Sep 19, 2023
82671f0
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Mar 19, 2024
86383dd
Fixing issues
Rexios80 Mar 19, 2024
2e51db9
Created HeatmapRadius class
Rexios80 Mar 19, 2024
fccb890
Auto add alpha zero color on web
Rexios80 Mar 19, 2024
272e276
Fixing serialization issues
Rexios80 Mar 19, 2024
57bb9c8
Pubspec version fix
Rexios80 Mar 19, 2024
c89ea1d
Merge branch 'main' into google-maps-heatmaps
Rexios80 Mar 19, 2024
01a2e09
Fix test
Rexios80 Mar 19, 2024
a0ec274
Merge remote-tracking branch 'origin/google-maps-heatmaps' into googl…
Rexios80 Mar 19, 2024
01ab1db
Merge branch 'main' into google-maps-heatmaps
Rexios80 Mar 19, 2024
761628b
Fixing iOS examples
Rexios80 Mar 19, 2024
609efce
Export HeatmapRadius
Rexios80 Mar 19, 2024
5e5fb1d
Use proper init method in inspectors
Rexios80 Mar 19, 2024
60411bd
Merge branch 'main' into google-maps-heatmaps
Rexios80 Mar 25, 2024
59b3d0b
Require data parameter and update documentation
Rexios80 Apr 25, 2024
fbc8d6f
Merge remote-tracking branch 'upstream/main' into bruh
Rexios80 Apr 25, 2024
7a9ca22
Fixing analysis issues
Rexios80 Apr 25, 2024
71d57be
Fix podspec and pubspec versions
Rexios80 Apr 25, 2024
41a1343
Merge branch 'main' into google-maps-heatmaps
Rexios80 May 7, 2024
7de09aa
Fix pubspec versions
Rexios80 May 7, 2024
846d30c
Create helper function for nil/null checks
Rexios80 May 8, 2024
c8de3ca
Add comment to mapView
Rexios80 May 8, 2024
7ba4f07
Add comment to radius in example
Rexios80 May 8, 2024
e84080d
Add geometry library to web example
Rexios80 May 8, 2024
de31155
Use key constants for serialization in dart code
Rexios80 May 8, 2024
3709e2a
Serialization constants for iOS
Rexios80 May 8, 2024
713eb84
Serialization constants on Android
Rexios80 May 8, 2024
8d32330
Add comments to FLTGoogleMapHeatmapController.h
Rexios80 May 8, 2024
810cba2
Add lightweight generics to dictionary
Rexios80 May 8, 2024
1bd4e7f
Name parameter
Rexios80 May 8, 2024
97b65bf
Add more lightweight generics
Rexios80 May 8, 2024
04c3ae8
More declaration comments
Rexios80 May 8, 2024
85a8b3a
Add static method for initialization
Rexios80 May 8, 2024
fa9dca5
Use different checks for heatmap interpretation
Rexios80 May 8, 2024
325f345
Use dictionary literals
Rexios80 May 8, 2024
7112a82
Fixes
Rexios80 May 8, 2024
4a167de
initWithCapacity
Rexios80 May 8, 2024
a025fa9
More fixes
Rexios80 May 8, 2024
2520b4d
Updated serialization constant comments
Rexios80 May 8, 2024
a453b1e
...
Rexios80 May 8, 2024
4792059
Temporary workaround for iOS building
Rexios80 May 8, 2024
fe3b4eb
Fix android test code
Rexios80 May 8, 2024
3c0d6f5
Formatting
Rexios80 May 8, 2024
e4fc0a2
Merge branch 'main' into google-maps-heatmaps
Rexios80 May 8, 2024
43e2109
Working on tests
Rexios80 May 8, 2024
9c3da8d
Merge remote-tracking branch 'origin/google-maps-heatmaps' into googl…
Rexios80 May 8, 2024
6f64acc
Remove reflection code
Rexios80 May 8, 2024
951cf0c
Tests work
Rexios80 May 8, 2024
451f00e
Formatting
Rexios80 May 8, 2024
70cf5d7
Fix analysis issue
Rexios80 May 8, 2024
fa1a22e
Skip inspector tests on Android
Rexios80 May 8, 2024
bd6240a
Add NonNull annotation
Rexios80 May 8, 2024
6ab687b
Push pod configuration change to maybe fix test
Rexios80 May 8, 2024
653aa67
Merge branch 'main' into google-maps-heatmaps
Rexios80 May 8, 2024
488b816
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Jun 23, 2024
f7712ad
Fixes
Rexios80 Jun 23, 2024
ce8e2e9
Refactor `HeatmapRadius`
Rexios80 Jun 23, 2024
f683902
Comment on default heatmap values
Rexios80 Jun 23, 2024
1953d81
Comment fix
Rexios80 Jun 23, 2024
3005347
Add comments to java code
Rexios80 Jun 23, 2024
ece01c5
Update iOS doc comments
Rexios80 Jun 23, 2024
9c846f7
Documentation updates for iOS
Rexios80 Jun 23, 2024
b6396b1
Refactor interpretHeatmapOptions
Rexios80 Jun 23, 2024
b504931
Inline getHeatmapInfo
Rexios80 Jun 23, 2024
8984d5c
Fixes
Rexios80 Jun 23, 2024
dbf8f03
Formatting
Rexios80 Jun 23, 2024
feba6dc
Fixing analysis
Rexios80 Jun 23, 2024
de85d29
Fixing CI
Rexios80 Jun 23, 2024
a72ddd4
Add license text
Rexios80 Jun 23, 2024
1bc2eae
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Jul 3, 2024
1fd4734
Updates for pigeon migration
Rexios80 Jul 3, 2024
391c641
Add java docs to Convert.java
Rexios80 Jul 3, 2024
03a8d0e
Merge branch 'main' into google-maps-heatmaps
Rexios80 Jul 3, 2024
46c4945
Merge branch 'tmp' into google-maps-heatmaps
Rexios80 Jul 31, 2024
ac706ea
Regenerate
Rexios80 Jul 31, 2024
8a6168c
Formatting
Rexios80 Jul 31, 2024
f303f33
Generate pigeons again
Rexios80 Aug 1, 2024
c0e65da
Working on iOS pigeons
Rexios80 Aug 1, 2024
8796aa8
iOS pigeon updates
Rexios80 Aug 1, 2024
9ae206a
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Aug 1, 2024
1ab336f
Regenerate
Rexios80 Aug 1, 2024
da3d5c8
Web fixes
Rexios80 Aug 1, 2024
867ee26
Fixing issues
Rexios80 Aug 1, 2024
7485164
Use new utils pod version
Rexios80 Aug 1, 2024
70fb796
Cleanup
Rexios80 Aug 1, 2024
e5fd458
Working on Convert.java tests
Rexios80 Aug 1, 2024
0097ea1
Working on Android native tests
Rexios80 Aug 1, 2024
51e3327
Add test for UpdateHeatmaps
Rexios80 Aug 1, 2024
d593363
Fixes
Rexios80 Aug 1, 2024
7b2f36d
Use federation compatibility check instead of skipping tests based on…
Rexios80 Aug 1, 2024
a8b5f01
Updates to match https://github.com/flutter/packages/pull/7056
Rexios80 Aug 1, 2024
6b4d1f6
Remove suppression
Rexios80 Aug 1, 2024
5655155
Make `interpretHeatmapOptions` private
Rexios80 Aug 1, 2024
4030fc3
Split test in two
Rexios80 Aug 1, 2024
4ca205c
Factor out test numbers
Rexios80 Aug 1, 2024
bd194c3
Fixing issues
Rexios80 Aug 1, 2024
fa762d4
Removes `HeatmapRadius.pixels` and adds TODO with implementation plan
Rexios80 Aug 1, 2024
c16eefd
Update podspec
Rexios80 Aug 1, 2024
0cebd36
Add tests for `heatmap.dart`
Rexios80 Aug 1, 2024
d8daea7
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Aug 1, 2024
d2ba2cb
Fix pubspec version
Rexios80 Aug 1, 2024
6dc10bb
Fixing analysis issues
Rexios80 Aug 1, 2024
cc0d228
Fixing things
Rexios80 Aug 1, 2024
b3cced4
Fixing iOS tests
Rexios80 Aug 1, 2024
5178037
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Aug 1, 2024
0a2cbaa
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Aug 5, 2024
fecebf7
Fixes
Rexios80 Aug 5, 2024
7999535
Fixes
Rexios80 Aug 5, 2024
9bd3646
Remove `serializeMapsObjectUpdates` from android/ios platforms
Rexios80 Aug 5, 2024
d4d9a55
Pigeon fixes
Rexios80 Aug 5, 2024
fb4b146
Remove extraneous heatmaps parameters
Rexios80 Aug 5, 2024
d65af57
Fix web tests
Rexios80 Aug 5, 2024
ca849aa
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Aug 5, 2024
cf178c2
Updates for platform interface release
Rexios80 Aug 5, 2024
d3d37c2
Merge remote-tracking branch 'upstream/main' into google-maps-heatmaps
Rexios80 Aug 6, 2024
6d6bfe2
Remove dependency overrides
Rexios80 Aug 6, 2024
f1bc422
Cleanup
Rexios80 Aug 6, 2024
f955eea
Replace `ignore` with `unawaited`
Rexios80 Aug 6, 2024
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,3 +1,7 @@
## 2.8.0

* Adds support for heatmap layers.

## 2.7.1

* Updates the example app to use TLHC mode, per current package guidance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui;

import 'package:flutter/foundation.dart';
Expand All @@ -21,6 +22,8 @@ void main() {
}

void runTests() {
const double floatTolerance = 1e-8;

GoogleMapsFlutterPlatform.instance.enableDebugInspection();

final GoogleMapsInspectorPlatform inspector =
Expand Down Expand Up @@ -204,6 +207,271 @@ void runTests() {
},
);
}, skip: isWeb /* Tiles not supported on the web */);

/// 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 || gradient2 == null) {
expect(gradient1, gradient2);
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: floatTolerance),
);
}

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

void expectHeatmapEquals(Heatmap heatmap1, Heatmap heatmap2) {
expectHeatmapDataMoreOrLessEquals(heatmap1.data, heatmap2.data);
expectHeatmapGradientMoreOrLessEquals(heatmap1.gradient, heatmap2.gradient);

// Only Android supports `maxIntensity`
// so the platform value is undefined on others.
bool canHandleMaxIntensity() {
return Platform.isAndroid;
}

// Only iOS supports `minimumZoomIntensity` and `maximumZoomIntensity`
// so the platform value is undefined on others.
bool canHandleZoomIntensity() {
return Platform.isIOS;
}

if (canHandleMaxIntensity()) {
expect(heatmap1.maxIntensity, heatmap2.maxIntensity);
}
expect(
heatmap1.opacity,
moreOrLessEquals(heatmap2.opacity, epsilon: floatTolerance),
);
expect(heatmap1.radius, heatmap2.radius);
if (canHandleZoomIntensity()) {
expect(heatmap1.minimumZoomIntensity, heatmap2.minimumZoomIntensity);
expect(heatmap1.maximumZoomIntensity, heatmap2.maximumZoomIntensity);
}
}

const Heatmap heatmap1 = Heatmap(
heatmapId: HeatmapId('heatmap_1'),
data: <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(
<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: HeatmapRadius.fromPixels(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!;

if (inspector.supportsGettingHeatmapInfo()) {
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: HeatmapRadius.fromPixels(heatmap1.radius.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));

if (inspector.supportsGettingHeatmapInfo()) {
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));

if (inspector.supportsGettingHeatmapInfo()) {
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 @@ -263,12 +263,12 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
"${PODS_ROOT}/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/Resources/GoogleMaps.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/GoogleMaps/GoogleMapsResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/google_maps_flutter_ios/google_maps_flutter_ios_privacy.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleMaps.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleMapsResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/google_maps_flutter_ios_privacy.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Loading