Skip to content

Commit

Permalink
[google_maps_flutter_web] Add clustering support
Browse files Browse the repository at this point in the history
  • Loading branch information
jokerttu committed Apr 25, 2024
1 parent fde908d commit ce387c9
Show file tree
Hide file tree
Showing 20 changed files with 627 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ Anton Borries <mail@antonborri.es>
Alex Li <google@alexv525.com>
Rahul Raj <64.rahulraj@gmail.com>
Justin Baumann <me@jxstxn.dev>
Joonas Kerttula <joonas.kerttula@codemate.com>
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.7

* Adds support for marker clustering.

## 0.5.6+2

* Uses `TrustedTypes` from `web: ^0.5.1`.
Expand Down
13 changes: 13 additions & 0 deletions packages/google_maps_flutter/google_maps_flutter_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ To request multiple libraries, separate them with commas:

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

## Marker clustering

If you need marker clustering support, modify the <head> tag to load the [js-markerclusterer](https://github.com/googlemaps/js-markerclusterer#install) library, like so:

```html
<head>

<!-- // Other stuff -->

<script src="https://unpkg.com/@googlemaps/markerclusterer@2.5.0/dist/index.min.js"></script>
</head>
```

## Limitations of the web version

The following map options are not available in web, because the map doesn't rotate there:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
returnValue: <_i4.CircleId, _i3.CircleController>{},
returnValueForMissingStub: <_i4.CircleId, _i3.CircleController>{},
) as Map<_i4.CircleId, _i3.CircleController>);

@override
_i2.GMap get googleMap => (super.noSuchMethod(
Invocation.getter(#googleMap),
Expand All @@ -55,7 +54,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
Invocation.getter(#googleMap),
),
) as _i2.GMap);

@override
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -64,14 +62,12 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
),
returnValueForMissingStub: null,
);

@override
int get mapId => (super.noSuchMethod(
Invocation.getter(#mapId),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);

@override
set mapId(int? _mapId) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -80,7 +76,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
),
returnValueForMissingStub: null,
);

@override
void addCircles(Set<_i4.Circle>? circlesToAdd) => super.noSuchMethod(
Invocation.method(
Expand All @@ -89,7 +84,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
),
returnValueForMissingStub: null,
);

@override
void changeCircles(Set<_i4.Circle>? circlesToChange) => super.noSuchMethod(
Invocation.method(
Expand All @@ -98,7 +92,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
),
returnValueForMissingStub: null,
);

@override
void removeCircles(Set<_i4.CircleId>? circleIdsToRemove) =>
super.noSuchMethod(
Expand All @@ -108,7 +101,6 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController {
),
returnValueForMissingStub: null,
);

@override
void bindToMap(
int? mapId,
Expand Down Expand Up @@ -137,7 +129,6 @@ class MockPolygonsController extends _i1.Mock
returnValue: <_i4.PolygonId, _i3.PolygonController>{},
returnValueForMissingStub: <_i4.PolygonId, _i3.PolygonController>{},
) as Map<_i4.PolygonId, _i3.PolygonController>);

@override
_i2.GMap get googleMap => (super.noSuchMethod(
Invocation.getter(#googleMap),
Expand All @@ -150,7 +141,6 @@ class MockPolygonsController extends _i1.Mock
Invocation.getter(#googleMap),
),
) as _i2.GMap);

@override
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -159,14 +149,12 @@ class MockPolygonsController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
int get mapId => (super.noSuchMethod(
Invocation.getter(#mapId),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);

@override
set mapId(int? _mapId) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -175,7 +163,6 @@ class MockPolygonsController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void addPolygons(Set<_i4.Polygon>? polygonsToAdd) => super.noSuchMethod(
Invocation.method(
Expand All @@ -184,7 +171,6 @@ class MockPolygonsController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void changePolygons(Set<_i4.Polygon>? polygonsToChange) => super.noSuchMethod(
Invocation.method(
Expand All @@ -193,7 +179,6 @@ class MockPolygonsController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void removePolygons(Set<_i4.PolygonId>? polygonIdsToRemove) =>
super.noSuchMethod(
Expand All @@ -203,7 +188,6 @@ class MockPolygonsController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void bindToMap(
int? mapId,
Expand Down Expand Up @@ -232,7 +216,6 @@ class MockPolylinesController extends _i1.Mock
returnValue: <_i4.PolylineId, _i3.PolylineController>{},
returnValueForMissingStub: <_i4.PolylineId, _i3.PolylineController>{},
) as Map<_i4.PolylineId, _i3.PolylineController>);

@override
_i2.GMap get googleMap => (super.noSuchMethod(
Invocation.getter(#googleMap),
Expand All @@ -245,7 +228,6 @@ class MockPolylinesController extends _i1.Mock
Invocation.getter(#googleMap),
),
) as _i2.GMap);

@override
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -254,14 +236,12 @@ class MockPolylinesController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
int get mapId => (super.noSuchMethod(
Invocation.getter(#mapId),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);

@override
set mapId(int? _mapId) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -270,7 +250,6 @@ class MockPolylinesController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void addPolylines(Set<_i4.Polyline>? polylinesToAdd) => super.noSuchMethod(
Invocation.method(
Expand All @@ -279,7 +258,6 @@ class MockPolylinesController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void changePolylines(Set<_i4.Polyline>? polylinesToChange) =>
super.noSuchMethod(
Expand All @@ -289,7 +267,6 @@ class MockPolylinesController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void removePolylines(Set<_i4.PolylineId>? polylineIdsToRemove) =>
super.noSuchMethod(
Expand All @@ -299,7 +276,6 @@ class MockPolylinesController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void bindToMap(
int? mapId,
Expand Down Expand Up @@ -327,7 +303,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
returnValue: <_i4.MarkerId, _i3.MarkerController>{},
returnValueForMissingStub: <_i4.MarkerId, _i3.MarkerController>{},
) as Map<_i4.MarkerId, _i3.MarkerController>);

@override
_i2.GMap get googleMap => (super.noSuchMethod(
Invocation.getter(#googleMap),
Expand All @@ -340,7 +315,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
Invocation.getter(#googleMap),
),
) as _i2.GMap);

@override
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -349,14 +323,12 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
int get mapId => (super.noSuchMethod(
Invocation.getter(#mapId),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);

@override
set mapId(int? _mapId) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -365,7 +337,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
void addMarkers(Set<_i4.Marker>? markersToAdd) => super.noSuchMethod(
Invocation.method(
Expand All @@ -374,7 +345,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
void changeMarkers(Set<_i4.Marker>? markersToChange) => super.noSuchMethod(
Invocation.method(
Expand All @@ -383,7 +353,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
void removeMarkers(Set<_i4.MarkerId>? markerIdsToRemove) =>
super.noSuchMethod(
Expand All @@ -393,7 +362,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
void showMarkerInfoWindow(_i4.MarkerId? markerId) => super.noSuchMethod(
Invocation.method(
Expand All @@ -402,7 +370,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
void hideMarkerInfoWindow(_i4.MarkerId? markerId) => super.noSuchMethod(
Invocation.method(
Expand All @@ -411,7 +378,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
),
returnValueForMissingStub: null,
);

@override
bool isInfoWindowShown(_i4.MarkerId? markerId) => (super.noSuchMethod(
Invocation.method(
Expand All @@ -421,7 +387,6 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController {
returnValue: false,
returnValueForMissingStub: false,
) as bool);

@override
void bindToMap(
int? mapId,
Expand Down Expand Up @@ -456,7 +421,6 @@ class MockTileOverlaysController extends _i1.Mock
Invocation.getter(#googleMap),
),
) as _i2.GMap);

@override
set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -465,14 +429,12 @@ class MockTileOverlaysController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
int get mapId => (super.noSuchMethod(
Invocation.getter(#mapId),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);

@override
set mapId(int? _mapId) => super.noSuchMethod(
Invocation.setter(
Expand All @@ -481,7 +443,6 @@ class MockTileOverlaysController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void addTileOverlays(Set<_i4.TileOverlay>? tileOverlaysToAdd) =>
super.noSuchMethod(
Expand All @@ -491,7 +452,6 @@ class MockTileOverlaysController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void changeTileOverlays(Set<_i4.TileOverlay>? tileOverlays) =>
super.noSuchMethod(
Expand All @@ -501,7 +461,6 @@ class MockTileOverlaysController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void removeTileOverlays(Set<_i4.TileOverlayId>? tileOverlayIds) =>
super.noSuchMethod(
Expand All @@ -511,7 +470,6 @@ class MockTileOverlaysController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void clearTileCache(_i4.TileOverlayId? tileOverlayId) => super.noSuchMethod(
Invocation.method(
Expand All @@ -520,7 +478,6 @@ class MockTileOverlaysController extends _i1.Mock
),
returnValueForMissingStub: null,
);

@override
void bindToMap(
int? mapId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ void main() {
});

testWidgets('isMarkerInfoWindowShown', (WidgetTester tester) async {
when(controller.isInfoWindowShown(any)).thenReturn(true);

const MarkerId markerId = MarkerId('testing-123');

when(controller.isInfoWindowShown(markerId)).thenReturn(true);

await plugin.isMarkerInfoWindowShown(markerId, mapId: mapId);

verify(controller.isInfoWindowShown(markerId));
Expand Down

0 comments on commit ce387c9

Please sign in to comment.