Skip to content

Commit c36c6a5

Browse files
committed
Docs: Update version and CHANGELOG for style fix
1 parent 37df035 commit c36c6a5

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

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.12+3
2+
3+
* Fixes a bug where using `cloudMapId` for cloud-based styling would fail if the `style` property was also present.
4+
15
## 0.5.12+2
26

37
* Fix broken cameraTargetBounds option on web.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async';
6+
import 'dart:js_util';
7+
8+
import 'package:google_maps_flutter_web/google_maps_flutter_web.dart';
9+
import 'package:flutter/widgets.dart';
10+
import 'package:flutter_test/flutter_test.dart';
11+
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
12+
import 'package:mockito/annotations.dart';
13+
import 'package:mockito/mockito.dart';
14+
// ignore: implementation_imports
15+
import 'package:google_maps_flutter_web/src/third_party/js_types/google_maps.dart'
16+
as gmaps;
17+
18+
import 'google_maps_controller_test.mocks.dart';
19+
import 'gmaps_mocks.dart';
20+
21+
const String _kCloudMapId = 'test-map-id';
22+
23+
@GenerateMocks(<Type>[
24+
StreamController,
25+
])
26+
void main() {
27+
late MockStreamController<MapEvent<Object?>> streamController;
28+
late MockMap map;
29+
30+
setUp(() {
31+
streamController = MockStreamController<MapEvent<Object?>>();
32+
map = MockMap();
33+
when(map.onTilesloaded).thenAnswer((_) => Stream<void>.value(null));
34+
when(map.onClick).thenAnswer(
35+
(_) => Stream<gmaps.MapMouseEvent>.value(MockMapMouseEvent()));
36+
when(map.onRightclick).thenAnswer(
37+
(_) => Stream<gmaps.MapMouseEvent>.value(MockMapMouseEvent()));
38+
when(map.onBoundsChanged).thenAnswer((_) => Stream<void>.value(null));
39+
when(map.onIdle).thenAnswer((_) => Stream<void>.value(null));
40+
when(map.isZoomDefined()).thenReturn(true);
41+
when(map.zoom).thenReturn(10);
42+
});
43+
44+
GoogleMapController createController({
45+
MapWidgetConfiguration widgetConfiguration = const MapWidgetConfiguration(
46+
initialCameraPosition: CameraPosition(target: LatLng(0, 0)),
47+
),
48+
MapObjects mapObjects = const MapObjects(),
49+
MapConfiguration mapConfiguration = const MapConfiguration(),
50+
}) {
51+
return GoogleMapController(
52+
mapId: 0,
53+
streamController: streamController,
54+
widgetConfiguration: widgetConfiguration,
55+
mapObjects: mapObjects,
56+
mapConfiguration: mapConfiguration,
57+
);
58+
}
59+
60+
testWidgets(
61+
'disables rotate control when fortyFiveDegreeImageryEnabled is disabled',
62+
(WidgetTester tester) async {
63+
gmaps.MapOptions? capturedOptions;
64+
final GoogleMapController controller = createController(
65+
mapConfiguration:
66+
const MapConfiguration(fortyFiveDegreeImageryEnabled: false));
67+
controller.debugSetOverrides(createMap: (_, gmaps.MapOptions options) {
68+
capturedOptions = options;
69+
return map;
70+
});
71+
72+
controller.init();
73+
74+
expect(capturedOptions, isNotNull);
75+
expect(capturedOptions!.rotateControl, isFalse);
76+
expect(capturedOptions!.tilt, 0);
77+
});
78+
79+
testWidgets('style is ignored when mapId is set',
80+
(WidgetTester tester) async {
81+
gmaps.MapOptions? capturedOptions;
82+
const String style =
83+
'''[{ "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{"color": "#6b9a76"}]}]''';
84+
final GoogleMapController controller = createController(
85+
mapConfiguration: const MapConfiguration(
86+
style: style,
87+
mapId: _kCloudMapId,
88+
));
89+
controller.debugSetOverrides(createMap: (_, gmaps.MapOptions options) {
90+
capturedOptions = options;
91+
return map;
92+
});
93+
94+
controller.init();
95+
96+
expect(capturedOptions, isNotNull);
97+
expect(capturedOptions!.styles, isNull,
98+
reason: 'styles should be null when mapId is provided.');
99+
expect(capturedOptions!.mapId, _kCloudMapId);
100+
});
101+
}

packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter_web
22
description: Web platform implementation of google_maps_flutter
33
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 0.5.12+2
5+
version: 0.5.12+3
66

77
environment:
88
sdk: ^3.6.0
@@ -31,6 +31,8 @@ dependencies:
3131
dev_dependencies:
3232
flutter_test:
3333
sdk: flutter
34+
build_runner: ^2.4.0
35+
mockito: ^5.4.0
3436

3537
topics:
3638
- google-maps

0 commit comments

Comments
 (0)