Skip to content

Commit cc47b06

Browse files
jokerttuditman
andauthored
[google_maps_flutter_web] Add marker clustering support (#6187)
This PR introduces support for marker clustering for Web platform This is prequel PR for: #4319 and sequel PR for: #6158 Containing only changes to `google_maps_flutter_web` package. Follow up PR will hold the app-facing plugin implementation. Linked issue: flutter/flutter#26863 --------- Co-authored-by: David Iglesias Teixeira <[email protected]>
1 parent bc6c186 commit cc47b06

20 files changed

+657
-107
lines changed

packages/google_maps_flutter/google_maps_flutter_web/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ Anton Borries <[email protected]>
6565
6666
Rahul Raj <[email protected]>
6767
Justin Baumann <[email protected]>
68+
Joonas Kerttula <[email protected]>

packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.7
2+
3+
* Adds support for marker clustering.
4+
15
## 0.5.6+2
26

37
* Uses `TrustedTypes` from `web: ^0.5.1`.

packages/google_maps_flutter/google_maps_flutter_web/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ To request multiple libraries, separate them with commas:
5050

5151
Now you should be able to use the Google Maps plugin normally.
5252

53+
## Marker clustering
54+
55+
If you need marker clustering support, modify the <head> tag to load the [js-markerclusterer](https://github.com/googlemaps/js-markerclusterer#install) library. Ensure you are using the currently supported version `2.5.3`, like so:
56+
57+
```html
58+
<head>
59+
60+
<!-- // Other stuff -->
61+
62+
<script src="https://unpkg.com/@googlemaps/[email protected]/dist/index.min.js"></script>
63+
</head>
64+
```
65+
5366
## Limitations of the web version
5467

5568
The following map options are not available in web, because the map doesn't rotate there:

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
4242
returnValue: <_i4.CircleId, _i3.CircleController>{},
4343
returnValueForMissingStub: <_i4.CircleId, _i3.CircleController>{},
4444
) as Map<_i4.CircleId, _i3.CircleController>);
45-
4645
@override
4746
_i2.GMap get googleMap => (super.noSuchMethod(
4847
Invocation.getter(#googleMap),
@@ -55,7 +54,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
5554
Invocation.getter(#googleMap),
5655
),
5756
) as _i2.GMap);
58-
5957
@override
6058
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
6159
Invocation.setter(
@@ -64,14 +62,12 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
6462
),
6563
returnValueForMissingStub: null,
6664
);
67-
6865
@override
6966
int get mapId => (super.noSuchMethod(
7067
Invocation.getter(#mapId),
7168
returnValue: 0,
7269
returnValueForMissingStub: 0,
7370
) as int);
74-
7571
@override
7672
set mapId(int? _mapId) => super.noSuchMethod(
7773
Invocation.setter(
@@ -80,7 +76,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
8076
),
8177
returnValueForMissingStub: null,
8278
);
83-
8479
@override
8580
void addCircles(Set<_i4.Circle>? circlesToAdd) => super.noSuchMethod(
8681
Invocation.method(
@@ -89,7 +84,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
8984
),
9085
returnValueForMissingStub: null,
9186
);
92-
9387
@override
9488
void changeCircles(Set<_i4.Circle>? circlesToChange) => super.noSuchMethod(
9589
Invocation.method(
@@ -98,7 +92,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
9892
),
9993
returnValueForMissingStub: null,
10094
);
101-
10295
@override
10396
void removeCircles(Set<_i4.CircleId>? circleIdsToRemove) =>
10497
super.noSuchMethod(
@@ -108,7 +101,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
108101
),
109102
returnValueForMissingStub: null,
110103
);
111-
112104
@override
113105
void bindToMap(
114106
int? mapId,
@@ -137,7 +129,6 @@ class MockPolygonsController extends _i1.Mock
137129
returnValue: <_i4.PolygonId, _i3.PolygonController>{},
138130
returnValueForMissingStub: <_i4.PolygonId, _i3.PolygonController>{},
139131
) as Map<_i4.PolygonId, _i3.PolygonController>);
140-
141132
@override
142133
_i2.GMap get googleMap => (super.noSuchMethod(
143134
Invocation.getter(#googleMap),
@@ -150,7 +141,6 @@ class MockPolygonsController extends _i1.Mock
150141
Invocation.getter(#googleMap),
151142
),
152143
) as _i2.GMap);
153-
154144
@override
155145
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
156146
Invocation.setter(
@@ -159,14 +149,12 @@ class MockPolygonsController extends _i1.Mock
159149
),
160150
returnValueForMissingStub: null,
161151
);
162-
163152
@override
164153
int get mapId => (super.noSuchMethod(
165154
Invocation.getter(#mapId),
166155
returnValue: 0,
167156
returnValueForMissingStub: 0,
168157
) as int);
169-
170158
@override
171159
set mapId(int? _mapId) => super.noSuchMethod(
172160
Invocation.setter(
@@ -175,7 +163,6 @@ class MockPolygonsController extends _i1.Mock
175163
),
176164
returnValueForMissingStub: null,
177165
);
178-
179166
@override
180167
void addPolygons(Set<_i4.Polygon>? polygonsToAdd) => super.noSuchMethod(
181168
Invocation.method(
@@ -184,7 +171,6 @@ class MockPolygonsController extends _i1.Mock
184171
),
185172
returnValueForMissingStub: null,
186173
);
187-
188174
@override
189175
void changePolygons(Set<_i4.Polygon>? polygonsToChange) => super.noSuchMethod(
190176
Invocation.method(
@@ -193,7 +179,6 @@ class MockPolygonsController extends _i1.Mock
193179
),
194180
returnValueForMissingStub: null,
195181
);
196-
197182
@override
198183
void removePolygons(Set<_i4.PolygonId>? polygonIdsToRemove) =>
199184
super.noSuchMethod(
@@ -203,7 +188,6 @@ class MockPolygonsController extends _i1.Mock
203188
),
204189
returnValueForMissingStub: null,
205190
);
206-
207191
@override
208192
void bindToMap(
209193
int? mapId,
@@ -232,7 +216,6 @@ class MockPolylinesController extends _i1.Mock
232216
returnValue: <_i4.PolylineId, _i3.PolylineController>{},
233217
returnValueForMissingStub: <_i4.PolylineId, _i3.PolylineController>{},
234218
) as Map<_i4.PolylineId, _i3.PolylineController>);
235-
236219
@override
237220
_i2.GMap get googleMap => (super.noSuchMethod(
238221
Invocation.getter(#googleMap),
@@ -245,7 +228,6 @@ class MockPolylinesController extends _i1.Mock
245228
Invocation.getter(#googleMap),
246229
),
247230
) as _i2.GMap);
248-
249231
@override
250232
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
251233
Invocation.setter(
@@ -254,14 +236,12 @@ class MockPolylinesController extends _i1.Mock
254236
),
255237
returnValueForMissingStub: null,
256238
);
257-
258239
@override
259240
int get mapId => (super.noSuchMethod(
260241
Invocation.getter(#mapId),
261242
returnValue: 0,
262243
returnValueForMissingStub: 0,
263244
) as int);
264-
265245
@override
266246
set mapId(int? _mapId) => super.noSuchMethod(
267247
Invocation.setter(
@@ -270,7 +250,6 @@ class MockPolylinesController extends _i1.Mock
270250
),
271251
returnValueForMissingStub: null,
272252
);
273-
274253
@override
275254
void addPolylines(Set<_i4.Polyline>? polylinesToAdd) => super.noSuchMethod(
276255
Invocation.method(
@@ -279,7 +258,6 @@ class MockPolylinesController extends _i1.Mock
279258
),
280259
returnValueForMissingStub: null,
281260
);
282-
283261
@override
284262
void changePolylines(Set<_i4.Polyline>? polylinesToChange) =>
285263
super.noSuchMethod(
@@ -289,7 +267,6 @@ class MockPolylinesController extends _i1.Mock
289267
),
290268
returnValueForMissingStub: null,
291269
);
292-
293270
@override
294271
void removePolylines(Set<_i4.PolylineId>? polylineIdsToRemove) =>
295272
super.noSuchMethod(
@@ -299,7 +276,6 @@ class MockPolylinesController extends _i1.Mock
299276
),
300277
returnValueForMissingStub: null,
301278
);
302-
303279
@override
304280
void bindToMap(
305281
int? mapId,
@@ -327,7 +303,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
327303
returnValue: <_i4.MarkerId, _i3.MarkerController>{},
328304
returnValueForMissingStub: <_i4.MarkerId, _i3.MarkerController>{},
329305
) as Map<_i4.MarkerId, _i3.MarkerController>);
330-
331306
@override
332307
_i2.GMap get googleMap => (super.noSuchMethod(
333308
Invocation.getter(#googleMap),
@@ -340,7 +315,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
340315
Invocation.getter(#googleMap),
341316
),
342317
) as _i2.GMap);
343-
344318
@override
345319
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
346320
Invocation.setter(
@@ -349,14 +323,12 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
349323
),
350324
returnValueForMissingStub: null,
351325
);
352-
353326
@override
354327
int get mapId => (super.noSuchMethod(
355328
Invocation.getter(#mapId),
356329
returnValue: 0,
357330
returnValueForMissingStub: 0,
358331
) as int);
359-
360332
@override
361333
set mapId(int? _mapId) => super.noSuchMethod(
362334
Invocation.setter(
@@ -365,7 +337,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
365337
),
366338
returnValueForMissingStub: null,
367339
);
368-
369340
@override
370341
void addMarkers(Set<_i4.Marker>? markersToAdd) => super.noSuchMethod(
371342
Invocation.method(
@@ -374,7 +345,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
374345
),
375346
returnValueForMissingStub: null,
376347
);
377-
378348
@override
379349
void changeMarkers(Set<_i4.Marker>? markersToChange) => super.noSuchMethod(
380350
Invocation.method(
@@ -383,7 +353,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
383353
),
384354
returnValueForMissingStub: null,
385355
);
386-
387356
@override
388357
void removeMarkers(Set<_i4.MarkerId>? markerIdsToRemove) =>
389358
super.noSuchMethod(
@@ -393,7 +362,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
393362
),
394363
returnValueForMissingStub: null,
395364
);
396-
397365
@override
398366
void showMarkerInfoWindow(_i4.MarkerId? markerId) => super.noSuchMethod(
399367
Invocation.method(
@@ -402,7 +370,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
402370
),
403371
returnValueForMissingStub: null,
404372
);
405-
406373
@override
407374
void hideMarkerInfoWindow(_i4.MarkerId? markerId) => super.noSuchMethod(
408375
Invocation.method(
@@ -411,7 +378,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
411378
),
412379
returnValueForMissingStub: null,
413380
);
414-
415381
@override
416382
bool isInfoWindowShown(_i4.MarkerId? markerId) => (super.noSuchMethod(
417383
Invocation.method(
@@ -421,7 +387,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
421387
returnValue: false,
422388
returnValueForMissingStub: false,
423389
) as bool);
424-
425390
@override
426391
void bindToMap(
427392
int? mapId,
@@ -456,7 +421,6 @@ class MockTileOverlaysController extends _i1.Mock
456421
Invocation.getter(#googleMap),
457422
),
458423
) as _i2.GMap);
459-
460424
@override
461425
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
462426
Invocation.setter(
@@ -465,14 +429,12 @@ class MockTileOverlaysController extends _i1.Mock
465429
),
466430
returnValueForMissingStub: null,
467431
);
468-
469432
@override
470433
int get mapId => (super.noSuchMethod(
471434
Invocation.getter(#mapId),
472435
returnValue: 0,
473436
returnValueForMissingStub: 0,
474437
) as int);
475-
476438
@override
477439
set mapId(int? _mapId) => super.noSuchMethod(
478440
Invocation.setter(
@@ -481,7 +443,6 @@ class MockTileOverlaysController extends _i1.Mock
481443
),
482444
returnValueForMissingStub: null,
483445
);
484-
485446
@override
486447
void addTileOverlays(Set<_i4.TileOverlay>? tileOverlaysToAdd) =>
487448
super.noSuchMethod(
@@ -491,7 +452,6 @@ class MockTileOverlaysController extends _i1.Mock
491452
),
492453
returnValueForMissingStub: null,
493454
);
494-
495455
@override
496456
void changeTileOverlays(Set<_i4.TileOverlay>? tileOverlays) =>
497457
super.noSuchMethod(
@@ -501,7 +461,6 @@ class MockTileOverlaysController extends _i1.Mock
501461
),
502462
returnValueForMissingStub: null,
503463
);
504-
505464
@override
506465
void removeTileOverlays(Set<_i4.TileOverlayId>? tileOverlayIds) =>
507466
super.noSuchMethod(
@@ -511,7 +470,6 @@ class MockTileOverlaysController extends _i1.Mock
511470
),
512471
returnValueForMissingStub: null,
513472
);
514-
515473
@override
516474
void clearTileCache(_i4.TileOverlayId? tileOverlayId) => super.noSuchMethod(
517475
Invocation.method(
@@ -520,7 +478,6 @@ class MockTileOverlaysController extends _i1.Mock
520478
),
521479
returnValueForMissingStub: null,
522480
);
523-
524481
@override
525482
void bindToMap(
526483
int? mapId,

packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,10 @@ void main() {
361361
});
362362

363363
testWidgets('isMarkerInfoWindowShown', (WidgetTester tester) async {
364-
when(controller.isInfoWindowShown(any)).thenReturn(true);
365-
366364
const MarkerId markerId = MarkerId('testing-123');
367365

366+
when(controller.isInfoWindowShown(markerId)).thenReturn(true);
367+
368368
await plugin.isMarkerInfoWindowShown(markerId, mapId: mapId);
369369

370370
verify(controller.isInfoWindowShown(markerId));

0 commit comments

Comments
 (0)