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_web] Migrate to google_maps: 8.0.0 #7077

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -33,34 +33,13 @@
<link rel="icon" type="image/png" href="favicon.png"/>

<title>Google Maps Web Example</title>

<link rel="manifest" href="manifest.json">

<!-- This API key comes from: go/flutter-maps-web-tests-api-key (GCP project: flutter-infra) -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAa9cRBkhuxGq3Xw3HPz8SPwaVOhRmm7kk&libraries=geometry"></script>

<script>
// The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
}
});
});
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ dev_dependencies:
plugin_platform_interface: ^2.1.7
stream_transform: ^2.0.0

# FOR TESTING ONLY DO NOT MERGE
dependency_overrides:
google_maps:
git:
url: https://github.com/a14n/dart-google-maps
ref: 0f57b7d99ed9652a31cd60a5dd4f3c6cb6b9f31a

topics:
- google-maps
- google-maps-flutter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.9

* Updates `package:google_maps` dependency to latest (`^8.0.0`).

## 0.5.8

* Adds support for BitmapDescriptor classes `AssetMapBitmap` and `BytesMapBitmap`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ import 'google_maps_controller_test.mocks.dart';
// LatLng values.
const String _kCloudMapId = '000000000000000'; // Dummy map ID.

gmaps.Map mapShim() => throw UnimplementedError();

@GenerateNiceMocks(<MockSpec<dynamic>>[
MockSpec<CirclesController>(),
MockSpec<PolygonsController>(),
MockSpec<PolylinesController>(),
MockSpec<MarkersController>(),
MockSpec<TileOverlaysController>(),
MockSpec<CirclesController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<PolygonsController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<PolylinesController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<MarkersController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
MockSpec<TileOverlaysController>(
fallbackGenerators: <Symbol, Function>{#googleMap: mapShim},
),
])

/// Test Google Map Controller
Expand Down Expand Up @@ -221,15 +233,15 @@ void main() {
late MockPolygonsController polygons;
late MockPolylinesController polylines;
late MockTileOverlaysController tileOverlays;
late gmaps.GMap map;
late gmaps.Map map;

setUp(() {
circles = MockCirclesController();
markers = MockMarkersController();
polygons = MockPolygonsController();
polylines = MockPolylinesController();
tileOverlays = MockTileOverlaysController();
map = gmaps.GMap(createDivElement());
map = gmaps.Map(createDivElement());
});

testWidgets('listens to map events', (WidgetTester tester) async {
Expand All @@ -246,19 +258,19 @@ void main() {
// Trigger events on the map, and verify they've been broadcast to the stream
final Stream<MapEvent<Object?>> capturedEvents = stream.stream.take(5);

gmaps.Event.trigger(
gmaps.event.trigger(
map,
'click',
<Object>[gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)],
gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0),
);
gmaps.Event.trigger(
gmaps.event.trigger(
map,
'rightclick',
<Object>[gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)],
gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0),
);
// The following line causes 2 events
gmaps.Event.trigger(map, 'bounds_changed', <Object>[]);
gmaps.Event.trigger(map, 'idle', <Object>[]);
gmaps.event.trigger(map, 'bounds_changed');
gmaps.event.trigger(map, 'idle');

final List<MapEvent<Object?>> events = await capturedEvents.toList();

Expand Down Expand Up @@ -539,12 +551,12 @@ void main() {
});
});

// These are the methods that are delegated to the gmaps.GMap object, that we can mock...
// These are the methods that are delegated to the gmaps.Map object, that we can mock...
group('Map control methods', () {
late gmaps.GMap map;
late gmaps.Map map;

setUp(() {
map = gmaps.GMap(
map = gmaps.Map(
createDivElement(),
gmaps.MapOptions()
..zoom = 10
Expand Down Expand Up @@ -604,7 +616,7 @@ void main() {

group('viewport getters', () {
testWidgets('getVisibleRegion', (WidgetTester tester) async {
final gmaps.LatLng gmCenter = map.center!;
final gmaps.LatLng gmCenter = map.center;
final LatLng center =
LatLng(gmCenter.lat.toDouble(), gmCenter.lng.toDouble());

Expand Down
Loading