From 6014043bfb17b5cbe7156c7ae5f5e6906260c240 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 6 Jul 2024 19:34:37 -0700 Subject: [PATCH 01/35] wip --- .../google_maps_controller_test.dart | 10 +++--- .../google_maps_plugin_test.dart | 4 +-- .../example/integration_test/marker_test.dart | 6 ++-- .../integration_test/markers_test.dart | 4 +-- .../integration_test/overlays_test.dart | 4 +-- .../example/integration_test/shapes_test.dart | 4 +-- .../example/pubspec.yaml | 4 +-- .../lib/src/convert.dart | 34 +++++++++---------- .../lib/src/google_maps_controller.dart | 22 ++++++------ .../lib/src/marker_clustering.dart | 4 +-- .../lib/src/marker_clustering_js_interop.dart | 14 ++++---- .../lib/src/overlay.dart | 2 +- .../to_screen_location.dart | 12 +++---- .../lib/src/types.dart | 8 ++--- .../google_maps_flutter_web/pubspec.yaml | 2 +- 15 files changed, 65 insertions(+), 69 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index d7c9ae288f4..c327f0d547d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -221,7 +221,7 @@ void main() { late MockPolygonsController polygons; late MockPolylinesController polylines; late MockTileOverlaysController tileOverlays; - late gmaps.GMap map; + late gmaps.Map map; setUp(() { circles = MockCirclesController(); @@ -229,7 +229,7 @@ void main() { polygons = MockPolygonsController(); polylines = MockPolylinesController(); tileOverlays = MockTileOverlaysController(); - map = gmaps.GMap(createDivElement()); + map = gmaps.Map(createDivElement()); }); testWidgets('listens to map events', (WidgetTester tester) async { @@ -539,12 +539,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 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart index b84b267c042..7ef410120b7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:js_util' show getProperty; +import 'dart:js_interop_unsafe'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -191,7 +191,7 @@ void main() { final gmaps.MapTypeStyle style = styles[0]; expect(style.featureType, 'poi.park'); expect(style.elementType, 'labels.text.fill'); - expect(style.stylers?.length, 1); + expect(style.stylers.length, 1); expect(getProperty(style.stylers![0]!, 'color'), '#6b9a76'); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 0b284cac766..0834022fed7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -124,7 +124,7 @@ void main() { testWidgets('showInfoWindow', (WidgetTester tester) async { final gmaps.InfoWindow infoWindow = gmaps.InfoWindow(); - final gmaps.GMap map = gmaps.GMap(createDivElement()); + final gmaps.Map map = gmaps.Map(createDivElement()); marker.set('map', map); final MarkerController controller = MarkerController( marker: marker, @@ -139,7 +139,7 @@ void main() { testWidgets('hideInfoWindow', (WidgetTester tester) async { final gmaps.InfoWindow infoWindow = gmaps.InfoWindow(); - final gmaps.GMap map = gmaps.GMap(createDivElement()); + final gmaps.Map map = gmaps.Map(createDivElement()); marker.set('map', map); final MarkerController controller = MarkerController( marker: marker, @@ -157,7 +157,7 @@ void main() { setUp(() { final gmaps.InfoWindow infoWindow = gmaps.InfoWindow(); - final gmaps.GMap map = gmaps.GMap(createDivElement()); + final gmaps.Map map = gmaps.Map(createDivElement()); marker.set('map', map); controller = MarkerController(marker: marker, infoWindow: infoWindow); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart index f068ec8db30..617fd905980 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart @@ -26,7 +26,7 @@ void main() { late StreamController> events; late MarkersController controller; late ClusterManagersController clusterManagersController; - late gmaps.GMap map; + late gmaps.Map map; setUp(() { events = StreamController>(); @@ -34,7 +34,7 @@ void main() { clusterManagersController = ClusterManagersController(stream: events); controller = MarkersController( stream: events, clusterManagersController: clusterManagersController); - map = gmaps.GMap(createDivElement()); + map = gmaps.Map(createDivElement()); clusterManagersController.bindToMap(123, map); controller.bindToMap(123, map); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart index c680c97a993..0959d8fcaa8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart @@ -32,7 +32,7 @@ void main() { group('TileOverlaysController', () { late TileOverlaysController controller; - late gmaps.GMap map; + late gmaps.Map map; late List tileProviders; late List tileOverlays; @@ -46,7 +46,7 @@ void main() { setUp(() { controller = TileOverlaysController(); - map = gmaps.GMap(createDivElement()); + map = gmaps.Map(createDivElement()); controller.googleMap = map; tileProviders = [ diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart index ad3d3d4a8a4..07b9c2604a9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart @@ -23,10 +23,10 @@ const double _acceptableDelta = 0.01; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - late gmaps.GMap map; + late gmaps.Map map; setUp(() { - map = gmaps.GMap(createDivElement()); + map = gmaps.Map(createDivElement()); }); group('CirclesController', () { diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 85a89ed5bf9..75e8aeee204 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -18,9 +18,9 @@ dev_dependencies: build_runner: ^2.1.1 flutter_test: sdk: flutter - google_maps: ^7.1.0 + google_maps: ^8.0.0-dev.1 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart - http: ">=0.13.0 <2.0.0" + http: ^1.0.0 integration_test: sdk: flutter mockito: 5.4.4 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index ee9100ddff0..20271b6ee57 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -195,12 +195,12 @@ LatLngBounds gmLatLngBoundsTolatLngBounds(gmaps.LatLngBounds latLngBounds) { ); } -CameraPosition _gmViewportToCameraPosition(gmaps.GMap map) { +CameraPosition _gmViewportToCameraPosition(gmaps.Map map) { return CameraPosition( - target: gmLatLngToLatLng(map.center ?? _nullGmapsLatLng), - bearing: map.heading?.toDouble() ?? 0, - tilt: map.tilt?.toDouble() ?? 0, - zoom: map.zoom?.toDouble() ?? 0, + target: gmLatLngToLatLng(map.center), + bearing: map.heading.toDouble() , + tilt: map.tilt.toDouble(), + zoom: map.zoom.toDouble(), ); } @@ -475,7 +475,7 @@ gmaps.CircleOptions _circleOptionsFromCircle(Circle circle) { } gmaps.PolygonOptions _polygonOptionsFromPolygon( - gmaps.GMap googleMap, Polygon polygon) { + gmaps.Map googleMap, Polygon polygon) { // Convert all points to GmLatLng final List path = polygon.points.map(_latLngToGmLatLng).toList(); @@ -550,7 +550,7 @@ bool _isPolygonClockwise(List path) { } gmaps.PolylineOptions _polylineOptionsFromPolyline( - gmaps.GMap googleMap, Polyline polyline) { + gmaps.Map googleMap, Polyline polyline) { final List paths = polyline.points.map(_latLngToGmLatLng).toList(); @@ -569,8 +569,8 @@ gmaps.PolylineOptions _polylineOptionsFromPolyline( // this.width = 10, } -// Translates a [CameraUpdate] into operations on a [gmaps.GMap]. -void _applyCameraUpdate(gmaps.GMap map, CameraUpdate update) { +// Translates a [CameraUpdate] into operations on a [gmaps.Map]. +void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { // Casts [value] to a JSON dictionary (string -> nullable object). [value] // must be a non-null JSON dictionary. Map asJsonObject(dynamic value) { @@ -587,10 +587,10 @@ void _applyCameraUpdate(gmaps.GMap map, CameraUpdate update) { case 'newCameraPosition': final Map position = asJsonObject(json[1]); final List latLng = asJsonList(position['target']); - map.heading = position['bearing'] as num?; - map.zoom = position['zoom'] as num?; + map.heading = position['bearing']! as num; + map.zoom = position['zoom']! as num; map.panTo( - gmaps.LatLng(latLng[0] as num?, latLng[1] as num?), + gmaps.LatLng(latLng[0]! as num, latLng[1]! as num), ); map.tilt = position['tilt'] as num?; case 'newLatLng': @@ -607,8 +607,8 @@ void _applyCameraUpdate(gmaps.GMap map, CameraUpdate update) { final double padding = json[2] as double; map.fitBounds( gmaps.LatLngBounds( - gmaps.LatLng(latLng1[0] as num?, latLng1[1] as num?), - gmaps.LatLng(latLng2[0] as num?, latLng2[1] as num?), + gmaps.LatLng(latLng1[0]! as num, latLng1[1]! as num), + gmaps.LatLng(latLng2[0]! as num, latLng2[1]! as num), ), padding, ); @@ -647,17 +647,15 @@ void _applyCameraUpdate(gmaps.GMap map, CameraUpdate update) { } // original JS by: Byron Singh (https://stackoverflow.com/a/30541162) -gmaps.LatLng _pixelToLatLng(gmaps.GMap map, int x, int y) { +gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final gmaps.LatLngBounds? bounds = map.bounds; final gmaps.Projection? projection = map.projection; - final num? zoom = map.zoom; + final num zoom = map.zoom; assert( bounds != null, 'Map Bounds required to compute LatLng of screen x/y.'); assert(projection != null, 'Map Projection required to compute LatLng of screen x/y'); - assert(zoom != null, - 'Current map zoom level required to compute LatLng of screen x/y'); final gmaps.LatLng ne = bounds!.northEast; final gmaps.LatLng sw = bounds.southWest; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 37c1e8a2fff..54ce4718936 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -6,14 +6,14 @@ part of '../google_maps_flutter_web.dart'; /// Type used when passing an override to the _createMap function. @visibleForTesting -typedef DebugCreateMapFunction = gmaps.GMap Function( +typedef DebugCreateMapFunction = gmaps.Map Function( HTMLElement div, gmaps.MapOptions options); /// Type used when passing an override to the _setOptions function. @visibleForTesting typedef DebugSetOptionsFunction = void Function(gmaps.MapOptions options); -/// Encapsulates a [gmaps.GMap], its events, and where in the DOM it's rendered. +/// Encapsulates a [gmaps.Map], its events, and where in the DOM it's rendered. class GoogleMapController { /// Initializes the GMap, and the sub-controllers related to it. Wires events. GoogleMapController({ @@ -45,7 +45,7 @@ class GoogleMapController { // Register the view factory that will hold the `_div` that holds the map in the DOM. // The `_div` needs to be created outside of the ViewFactory (and cached!) so we can - // use it to create the [gmaps.GMap] in the `init()` method of this class. + // use it to create the [gmaps.Map] in the `init()` method of this class. _div = createDivElement() ..id = _getViewType(mapId) ..style.width = '100%' @@ -108,7 +108,7 @@ class GoogleMapController { gmaps.TrafficLayer? get trafficLayer => _trafficLayer; // The underlying GMap instance. This is the interface with the JS SDK. - gmaps.GMap? _googleMap; + gmaps.Map? _googleMap; // The StreamController used by this controller and the geometry ones. final StreamController> _streamController; @@ -164,11 +164,11 @@ class GoogleMapController { DebugCreateMapFunction? _overrideCreateMap; DebugSetOptionsFunction? _overrideSetOptions; - gmaps.GMap _createMap(HTMLElement div, gmaps.MapOptions options) { + gmaps.Map _createMap(HTMLElement div, gmaps.MapOptions options) { if (_overrideCreateMap != null) { return _overrideCreateMap!(div, options); } - return gmaps.GMap(div, options); + return gmaps.Map(div, options); } /// A flag that returns true if the controller has been initialized or not. @@ -179,7 +179,7 @@ class GoogleMapController { /// /// (Also initializes the geometry/traffic layers.) /// - /// The first part of this method starts the rendering of a [gmaps.GMap] inside + /// The first part of this method starts the rendering of a [gmaps.Map] inside /// of the target [_div], with configuration from `rawOptions`. It then stores /// the created GMap in the [_googleMap] attribute. /// @@ -207,7 +207,7 @@ class GoogleMapController { } // Create the map... - final gmaps.GMap map = _createMap(_div, options); + final gmaps.Map map = _createMap(_div, options); _googleMap = map; _attachMapEvents(map); @@ -221,7 +221,7 @@ class GoogleMapController { } // Funnels map gmap events into the plugin's stream controller. - void _attachMapEvents(gmaps.GMap map) { + void _attachMapEvents(gmaps.Map map) { map.onTilesloaded.first.then((void _) { // Report the map as ready to go the first time the tiles load _streamController.add(WebMapReadyEvent(_mapId)); @@ -254,7 +254,7 @@ class GoogleMapController { } // Binds the Geometry controllers to a map instance - void _attachGeometryControllers(gmaps.GMap map) { + void _attachGeometryControllers(gmaps.Map map) { // Now we can add the initial geometry. // And bind the (ready) map instance to the other geometry controllers. // @@ -373,7 +373,7 @@ class GoogleMapController { } // Attaches/detaches a Traffic Layer on the passed `map` if `attach` is true/false. - void _setTrafficLayer(gmaps.GMap map, bool attach) { + void _setTrafficLayer(gmaps.Map map, bool attach) { if (attach && _trafficLayer == null) { _trafficLayer = gmaps.TrafficLayer()..set('map', map); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart index d4b5ed3bd70..89ad41bd481 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart @@ -43,7 +43,7 @@ class ClusterManagersController extends GeometryController { final MarkerClusterer markerClusterer = createMarkerClusterer( googleMap, (gmaps.MapMouseEvent event, MarkerClustererCluster cluster, - gmaps.GMap map) => + gmaps.Map map) => _clusterClicked( clusterManager.clusterManagerId, event, cluster, map)); @@ -109,7 +109,7 @@ class ClusterManagersController extends GeometryController { ClusterManagerId clusterManagerId, gmaps.MapMouseEvent event, MarkerClustererCluster markerClustererCluster, - gmaps.GMap map) { + gmaps.Map map) { if (markerClustererCluster.count > 0 && markerClustererCluster.bounds != null) { final Cluster cluster = diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart index e3bf42b4e71..80e7e5fc1c1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart @@ -16,7 +16,7 @@ import 'package:google_maps/google_maps.dart' as gmaps; typedef ClusterClickHandler = void Function( gmaps.MapMouseEvent, MarkerClustererCluster, - gmaps.GMap, + gmaps.Map, ); /// The [MarkerClustererOptions] object used to initialize [MarkerClusterer]. @@ -27,7 +27,7 @@ typedef ClusterClickHandler = void Function( extension type MarkerClustererOptions._(JSObject _) implements JSObject { /// Constructs a new [MarkerClustererOptions] object. factory MarkerClustererOptions({ - gmaps.GMap? map, + gmaps.Map? map, List? markers, ClusterClickHandler? onClusterClick, }) => @@ -37,7 +37,7 @@ extension type MarkerClustererOptions._(JSObject _) implements JSObject { onClusterClick: onClusterClick != null ? ((JSAny event, MarkerClustererCluster cluster, JSAny map) => onClusterClick(event as gmaps.MapMouseEvent, cluster, - map as gmaps.GMap)).toJS + map as gmaps.Map)).toJS : null, ); @@ -47,8 +47,8 @@ extension type MarkerClustererOptions._(JSObject _) implements JSObject { JSFunction? onClusterClick, }); - /// Returns the [gmaps.GMap] object. - gmaps.GMap? get map => _map as gmaps.GMap?; + /// Returns the [gmaps.Map] object. + gmaps.Map? get map => _map as gmaps.Map?; @JS('map') external JSAny? get _map; @@ -152,10 +152,10 @@ extension type MarkerClusterer._(JSObject _) implements JSObject { external void render(); } -/// Creates [MarkerClusterer] object with given [gmaps.GMap] and +/// Creates [MarkerClusterer] object with given [gmaps.Map] and /// [ClusterClickHandler]. MarkerClusterer createMarkerClusterer( - gmaps.GMap map, ClusterClickHandler onClusterClickHandler) { + gmaps.Map map, ClusterClickHandler onClusterClickHandler) { final MarkerClustererOptions options = MarkerClustererOptions( map: map, onClusterClick: onClusterClickHandler, diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart index 29823d00b9f..1b4de3e9f4c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart @@ -49,7 +49,7 @@ class TileOverlayController { img.setAttribute('decoding', 'async'); _tileOverlay.tileProvider! - .getTile(tileCoord!.x!.toInt(), tileCoord.y!.toInt(), zoom?.toInt()) + .getTile(tileCoord!.x.toInt(), tileCoord.y.toInt(), zoom?.toInt()) .then((Tile tile) { if (tile.data == null) { return; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart index fc25b18b43e..2e8d23a8b8b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart @@ -28,8 +28,8 @@ import 'package:google_maps/google_maps.dart' as gmaps; /// (not of the whole screen/app). /// /// See: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/Projection#public-point-toscreenlocation-latlng-location -gmaps.Point toScreenLocation(gmaps.GMap map, gmaps.LatLng coords) { - final num? zoom = map.zoom; +gmaps.Point toScreenLocation(gmaps.Map map, gmaps.LatLng coords) { + final num zoom = map.zoom; final gmaps.LatLngBounds? bounds = map.bounds; final gmaps.Projection? projection = map.projection; @@ -37,8 +37,6 @@ gmaps.Point toScreenLocation(gmaps.GMap map, gmaps.LatLng coords) { bounds != null, 'Map Bounds required to compute screen x/y of LatLng.'); assert(projection != null, 'Map Projection required to compute screen x/y of LatLng.'); - assert(zoom != null, - 'Current map zoom level required to compute screen x/y of LatLng.'); final gmaps.LatLng ne = bounds!.northEast; final gmaps.LatLng sw = bounds.southWest; @@ -46,12 +44,12 @@ gmaps.Point toScreenLocation(gmaps.GMap map, gmaps.LatLng coords) { final gmaps.Point topRight = projection!.fromLatLngToPoint!(ne)!; final gmaps.Point bottomLeft = projection.fromLatLngToPoint!(sw)!; - final int scale = 1 << (zoom!.toInt()); // 2 ^ zoom + final int scale = 1 << (zoom.toInt()); // 2 ^ zoom final gmaps.Point worldPoint = projection.fromLatLngToPoint!(coords)!; return gmaps.Point( - ((worldPoint.x! - bottomLeft.x!) * scale).toInt(), - ((worldPoint.y! - topRight.y!) * scale).toInt(), + ((worldPoint.x - bottomLeft.x) * scale).toInt(), + ((worldPoint.y - topRight.y) * scale).toInt(), ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/types.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/types.dart index d4e87799f4b..1eec81a4f1e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/types.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/types.dart @@ -14,17 +14,17 @@ typedef LatLngCallback = void Function(gmaps.LatLng latLng); /// The base class for all "geometry" group controllers. /// /// This lets all Geometry controllers ([MarkersController], [CirclesController], -/// [PolygonsController], [PolylinesController]) to be bound to a [gmaps.GMap] +/// [PolygonsController], [PolylinesController]) to be bound to a [gmaps.Map] /// instance and our internal `mapId` value. abstract class GeometryController { /// The GMap instance that this controller operates on. - late gmaps.GMap googleMap; + late gmaps.Map googleMap; /// The map ID for events. late int mapId; - /// Binds a `mapId` and the [gmaps.GMap] instance to this controller. - void bindToMap(int mapId, gmaps.GMap googleMap) { + /// Binds a `mapId` and the [gmaps.Map] instance to this controller. + void bindToMap(int mapId, gmaps.Map googleMap) { this.mapId = mapId; this.googleMap = googleMap; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 76707dd7c1e..5f170f73414 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - google_maps: ^7.1.0 + google_maps: ^8.0.0-dev.1 google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 From 84445f17453648b3a3aa8404ace0fe57ce3a4107 Mon Sep 17 00:00:00 2001 From: Rexios Date: Sun, 7 Jul 2024 13:41:50 -0400 Subject: [PATCH 02/35] Working on migration --- .../google_maps_controller_test.dart | 15 +++++----- .../google_maps_plugin_test.dart | 2 +- .../example/integration_test/marker_test.dart | 18 +++++++----- .../integration_test/markers_test.dart | 10 +++---- .../integration_test/overlay_test.dart | 2 +- .../integration_test/overlays_test.dart | 3 +- .../example/integration_test/shape_test.dart | 9 +++--- .../example/integration_test/shapes_test.dart | 4 +-- .../lib/src/convert.dart | 28 +++++++++---------- .../lib/src/google_maps_controller.dart | 9 ++---- .../lib/src/markers.dart | 2 +- .../lib/src/overlays.dart | 6 ++-- 12 files changed, 56 insertions(+), 52 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index c327f0d547d..ba0924be8aa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -246,19 +247,19 @@ void main() { // Trigger events on the map, and verify they've been broadcast to the stream final Stream> capturedEvents = stream.stream.take(5); - gmaps.Event.trigger( + gmaps.event.trigger( map, 'click', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)], + [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, ); - gmaps.Event.trigger( + gmaps.event.trigger( map, 'rightclick', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)], + [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, ); // The following line causes 2 events - gmaps.Event.trigger(map, 'bounds_changed', []); - gmaps.Event.trigger(map, 'idle', []); + gmaps.event.trigger(map, 'bounds_changed', [].toJS); + gmaps.event.trigger(map, 'idle', [].toJS); final List> events = await capturedEvents.toList(); @@ -604,7 +605,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()); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart index 7ef410120b7..fdd9e6e5ef8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart @@ -192,7 +192,7 @@ void main() { expect(style.featureType, 'poi.park'); expect(style.elementType, 'labels.text.fill'); expect(style.stylers.length, 1); - expect(getProperty(style.stylers![0]!, 'color'), '#6b9a76'); + expect(style.stylers[0]['color'], '#6b9a76'); }); testWidgets('throws MapStyleException for invalid styles', diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 0834022fed7..6223493417f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_maps/google_maps.dart' as gmaps; @@ -56,7 +57,7 @@ void main() { MarkerController(marker: marker, onTap: onTap); // Trigger a click event... - gmaps.Event.trigger(marker, 'click', [gmaps.MapMouseEvent()]); + gmaps.event.trigger(marker, 'click', [gmaps.MapMouseEvent()].toJS); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -66,8 +67,11 @@ void main() { MarkerController(marker: marker, onDragStart: onDragStart); // Trigger a drag end event... - gmaps.Event.trigger(marker, 'dragstart', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)]); + gmaps.event.trigger( + marker, + 'dragstart', + [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, + ); expect(await methodCalled, isTrue); }); @@ -76,10 +80,10 @@ void main() { MarkerController(marker: marker, onDrag: onDrag); // Trigger a drag end event... - gmaps.Event.trigger( + gmaps.event.trigger( marker, 'drag', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)], + [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, ); expect(await methodCalled, isTrue); @@ -89,10 +93,10 @@ void main() { MarkerController(marker: marker, onDragEnd: onDragEnd); // Trigger a drag end event... - gmaps.Event.trigger( + gmaps.event.trigger( marker, 'dragend', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)], + [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, ); expect(await methodCalled, isTrue); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart index 617fd905980..8de4a504149 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart @@ -230,7 +230,7 @@ void main() { controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); - final String assetUrl = icon!.url!; + final String assetUrl = icon!.url; expect(assetUrl, startsWith('assets')); final gmaps.Size size = icon.size!; @@ -262,7 +262,7 @@ void main() { controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); - final String assetUrl = icon!.url!; + final String assetUrl = icon!.url; expect(assetUrl, startsWith('assets')); final gmaps.Size size = icon.size!; @@ -297,7 +297,7 @@ void main() { controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); - final String assetUrl = icon!.url!; + final String assetUrl = icon!.url; expect(assetUrl, startsWith('assets')); final gmaps.Size size = icon.size!; @@ -330,7 +330,7 @@ void main() { controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); - final String assetUrl = icon!.url!; + final String assetUrl = icon!.url; expect(assetUrl, startsWith('assets')); // For invalid assets, the size and scaledSize should be null. @@ -360,7 +360,7 @@ void main() { controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); - final String blobUrl = icon!.url!; + final String blobUrl = icon!.url; expect(blobUrl, startsWith('blob:')); final http.Response response = await http.get(Uri.parse(blobUrl)); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart index 0724da21127..2cecc325223 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart @@ -41,7 +41,7 @@ void main() { tileOverlay: const TileOverlay(tileOverlayId: id), ); - final gmaps.Size size = controller.gmMapType.tileSize!; + final gmaps.Size size = controller.gmMapType.tileSize; expect(size.width, TileOverlayController.logicalTileSize); expect(size.height, TileOverlayController.logicalTileSize); expect( diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart index 0959d8fcaa8..8e6b178dd25 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -39,7 +40,7 @@ void main() { /// Queries the current overlay map types for tiles at x = 0, y = 0, zoom = /// 0. void probeTiles() { - for (final gmaps.MapType? mapType in map.overlayMapTypes!.array!) { + for (final gmaps.MapType? mapType in map.overlayMapTypes.array.toDart) { mapType?.getTile!(gmaps.Point(0, 0), 0, document); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart index 11af181cffc..73c8481ae3b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_maps/google_maps.dart' as gmaps; @@ -35,14 +36,14 @@ void main() { late gmaps.Circle circle; setUp(() { - circle = gmaps.Circle(); + circle = gmaps.Circle(gmaps.CircleOptions()); }); testWidgets('onTap gets called', (WidgetTester tester) async { CircleController(circle: circle, consumeTapEvents: true, onTap: onTap); // Trigger a click event... - gmaps.Event.trigger(circle, 'click', [gmaps.MapMouseEvent()]); + gmaps.event.trigger(circle, 'click', [gmaps.MapMouseEvent()].toJS); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -98,7 +99,7 @@ void main() { PolygonController(polygon: polygon, consumeTapEvents: true, onTap: onTap); // Trigger a click event... - gmaps.Event.trigger(polygon, 'click', [gmaps.MapMouseEvent()]); + gmaps.event.trigger(polygon, 'click', [gmaps.MapMouseEvent()].toJS); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -158,7 +159,7 @@ void main() { ); // Trigger a click event... - gmaps.Event.trigger(polyline, 'click', [gmaps.MapMouseEvent()]); + gmaps.event.trigger(polyline, 'click', [gmaps.MapMouseEvent()].toJS); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart index 07b9c2604a9..42b0e5b0fef 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart @@ -253,7 +253,7 @@ void main() { final gmaps.Polygon? polygon = controller.polygons.values.first.polygon; final gmaps.LatLng pointInHole = gmaps.LatLng(28.632, -68.401); - expect(geometry.Poly.containsLocation(pointInHole, polygon), false); + expect(geometry.poly.containsLocation(pointInHole, polygon!), false); }); testWidgets('Hole Path gets reversed to display correctly', @@ -279,7 +279,7 @@ void main() { controller.addPolygons(polygons); final gmaps.MVCArray?> paths = - controller.polygons.values.first.polygon!.paths!; + controller.polygons.values.first.polygon!.paths; expect(paths.getAt(1)?.getAt(0)?.lat, 28.745); expect(paths.getAt(1)?.getAt(1)?.lat, 29.57); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 20271b6ee57..dc981c3a86b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -496,7 +496,7 @@ gmaps.PolygonOptions _polygonOptionsFromPolygon( } return gmaps.PolygonOptions() - ..paths = paths + ..paths = paths.map((e) => e.toJS).toList().toJS ..strokeColor = _getCssColor(polygon.strokeColor) ..strokeOpacity = _getCssOpacity(polygon.strokeColor) ..strokeWeight = polygon.strokeWidth @@ -555,7 +555,7 @@ gmaps.PolylineOptions _polylineOptionsFromPolyline( polyline.points.map(_latLngToGmLatLng).toList(); return gmaps.PolylineOptions() - ..path = paths + ..path = paths.toJS ..strokeWeight = polyline.width ..strokeColor = _getCssColor(polyline.color) ..strokeOpacity = _getCssOpacity(polyline.color) @@ -592,14 +592,14 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { map.panTo( gmaps.LatLng(latLng[0]! as num, latLng[1]! as num), ); - map.tilt = position['tilt'] as num?; + map.tilt = position['tilt']! as num; case 'newLatLng': final List latLng = asJsonList(json[1]); - map.panTo(gmaps.LatLng(latLng[0] as num?, latLng[1] as num?)); + map.panTo(gmaps.LatLng(latLng[0]! as num, latLng[1]! as num)); case 'newLatLngZoom': final List latLng = asJsonList(json[1]); - map.zoom = json[2] as num?; - map.panTo(gmaps.LatLng(latLng[0] as num?, latLng[1] as num?)); + map.zoom = json[2]! as num; + map.panTo(gmaps.LatLng(latLng[0]! as num, latLng[1]! as num)); case 'newLatLngBounds': final List latLngPair = asJsonList(json[1]); final List latLng1 = asJsonList(latLngPair[0]); @@ -610,10 +610,10 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { gmaps.LatLng(latLng1[0]! as num, latLng1[1]! as num), gmaps.LatLng(latLng2[0]! as num, latLng2[1]! as num), ), - padding, + padding.toJS, ); case 'scrollBy': - map.panBy(json[1] as num?, json[2] as num?); + map.panBy(json[1]! as num, json[2]! as num); case 'zoomBy': gmaps.LatLng? focusLatLng; final double zoomDelta = json[1] as double? ?? 0; @@ -631,16 +631,16 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { // print('Error computing new focus LatLng. JS Error: ' + e.toString()); } } - map.zoom = (map.zoom ?? 0) + newZoomDelta; + map.zoom = (map.zoom) + newZoomDelta; if (focusLatLng != null) { map.panTo(focusLatLng); } case 'zoomIn': - map.zoom = (map.zoom ?? 0) + 1; + map.zoom = (map.zoom) + 1; case 'zoomOut': - map.zoom = (map.zoom ?? 0) - 1; + map.zoom = (map.zoom) - 1; case 'zoomTo': - map.zoom = json[1] as num?; + map.zoom = json[1]! as num; default: throw UnimplementedError('Unimplemented CameraMove: ${json[0]}.'); } @@ -663,10 +663,10 @@ gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final gmaps.Point topRight = projection!.fromLatLngToPoint!(ne)!; final gmaps.Point bottomLeft = projection.fromLatLngToPoint!(sw)!; - final int scale = 1 << (zoom!.toInt()); // 2 ^ zoom + final int scale = 1 << (zoom.toInt()); // 2 ^ zoom final gmaps.Point point = - gmaps.Point((x / scale) + bottomLeft.x!, (y / scale) + topRight.y!); + gmaps.Point((x / scale) + bottomLeft.x, (y / scale) + topRight.y); return projection.fromPointToLatLng!(point)!; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 54ce4718936..59dafe485a5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -226,7 +226,7 @@ class GoogleMapController { // Report the map as ready to go the first time the tiles load _streamController.add(WebMapReadyEvent(_mapId)); }); - map.onClick.listen((gmaps.IconMouseEvent event) { + map.onClick.listen((gmaps.MapMouseEventOrIconMouseEvent event) { assert(event.latLng != null); _streamController.add( MapTapEvent(_mapId, gmLatLngToLatLng(event.latLng!)), @@ -405,7 +405,7 @@ class GoogleMapController { final gmaps.Point point = toScreenLocation(_googleMap!, _latLngToGmLatLng(latLng)); - return ScreenCoordinate(x: point.x!.toInt(), y: point.y!.toInt()); + return ScreenCoordinate(x: point.x.toInt(), y: point.y.toInt()); } /// Returns the [LatLng] for a `screenCoordinate` (in pixels) of the viewport. @@ -428,10 +428,7 @@ class GoogleMapController { /// Returns the zoom level of the current viewport. Future getZoomLevel() async { assert(_googleMap != null, 'Cannot get zoom level of a null map.'); - assert(_googleMap!.zoom != null, - 'Zoom level should not be null. Is the map correctly initialized?'); - - return _googleMap!.zoom!.toDouble(); + return _googleMap!.zoom.toDouble(); } // Geometry manipulation diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart index 8bcf8b7f942..f5204403528 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart @@ -60,7 +60,7 @@ class MarkersController extends GeometryController { final gmaps.Marker gmMarker = gmaps.Marker(markerOptions); - gmMarker.set('markerId', marker.markerId.value); + gmMarker.set('markerId', marker.markerId.value.toJS); if (marker.clusterManagerId != null) { _clusterManagersController.addItem(marker.clusterManagerId!, gmMarker); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart index 26c6a7573a4..59015a4e4b9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart @@ -19,7 +19,7 @@ class TileOverlaysController extends GeometryController { tileOverlayController, (TileOverlayController c) => c.tileOverlay.zIndex); - googleMap.overlayMapTypes!.insertAt(index, tileOverlayController.gmMapType); + googleMap.overlayMapTypes.insertAt(index, tileOverlayController.gmMapType); _visibleTileOverlays.insert(index, tileOverlayController); } @@ -30,7 +30,7 @@ class TileOverlaysController extends GeometryController { return; } - googleMap.overlayMapTypes!.removeAt(index); + googleMap.overlayMapTypes.removeAt(index); _visibleTileOverlays.removeAt(index); } @@ -93,7 +93,7 @@ class TileOverlaysController extends GeometryController { if (controller != null && controller.tileOverlay.visible) { final int i = _visibleTileOverlays.indexOf(controller); // This causes the map to reload the overlay. - googleMap.overlayMapTypes!.setAt(i, controller.gmMapType); + googleMap.overlayMapTypes.setAt(i, controller.gmMapType); } } } From afb21bc501403de977c404c995cbc41502381d9b Mon Sep 17 00:00:00 2001 From: Rexios Date: Sun, 7 Jul 2024 15:34:27 -0400 Subject: [PATCH 03/35] Remove unnecessary null checks --- .../example/integration_test/overlay_test.dart | 10 +++++----- .../example/integration_test/overlays_test.dart | 2 +- .../google_maps_flutter_web/lib/src/convert.dart | 6 +++--- .../to_screen_location/to_screen_location.dart | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart index 2cecc325223..39b840eaa21 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart @@ -45,7 +45,7 @@ void main() { expect(size.width, TileOverlayController.logicalTileSize); expect(size.height, TileOverlayController.logicalTileSize); expect( - controller.gmMapType.getTile!(gmaps.Point(0, 0), 0, document), + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document), null, ); }); @@ -59,7 +59,7 @@ void main() { ); final HTMLImageElement img = - controller.gmMapType.getTile!(gmaps.Point(0, 0), 0, document)! + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; expect(img.naturalWidth, 0); expect(img.naturalHeight, 0); @@ -83,7 +83,7 @@ void main() { ); { final HTMLImageElement img = - controller.gmMapType.getTile!(gmaps.Point(0, 0), 0, document)! + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; await null; // let `getTile` `then` complete expect( @@ -99,7 +99,7 @@ void main() { )); { final HTMLImageElement img = - controller.gmMapType.getTile!(gmaps.Point(0, 0), 0, document)! + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; await img.onLoad.first; @@ -114,7 +114,7 @@ void main() { controller.update(const TileOverlay(tileOverlayId: id)); { expect( - controller.gmMapType.getTile!(gmaps.Point(0, 0), 0, document), + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document), null, reason: 'Setting a null tileProvider should work.', ); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart index 8e6b178dd25..1b5b8af5f02 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart @@ -41,7 +41,7 @@ void main() { /// 0. void probeTiles() { for (final gmaps.MapType? mapType in map.overlayMapTypes.array.toDart) { - mapType?.getTile!(gmaps.Point(0, 0), 0, document); + mapType?.getTile(gmaps.Point(0, 0), 0, document); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index dc981c3a86b..d1ee29762de 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -660,13 +660,13 @@ gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final gmaps.LatLng ne = bounds!.northEast; final gmaps.LatLng sw = bounds.southWest; - final gmaps.Point topRight = projection!.fromLatLngToPoint!(ne)!; - final gmaps.Point bottomLeft = projection.fromLatLngToPoint!(sw)!; + final gmaps.Point topRight = projection!.fromLatLngToPoint(ne)!; + final gmaps.Point bottomLeft = projection.fromLatLngToPoint(sw)!; final int scale = 1 << (zoom.toInt()); // 2 ^ zoom final gmaps.Point point = gmaps.Point((x / scale) + bottomLeft.x, (y / scale) + topRight.y); - return projection.fromPointToLatLng!(point)!; + return projection.fromPointToLatLng(point)!; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart index 2e8d23a8b8b..ca031e3fd3a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart @@ -41,12 +41,12 @@ gmaps.Point toScreenLocation(gmaps.Map map, gmaps.LatLng coords) { final gmaps.LatLng ne = bounds!.northEast; final gmaps.LatLng sw = bounds.southWest; - final gmaps.Point topRight = projection!.fromLatLngToPoint!(ne)!; - final gmaps.Point bottomLeft = projection.fromLatLngToPoint!(sw)!; + final gmaps.Point topRight = projection!.fromLatLngToPoint(ne)!; + final gmaps.Point bottomLeft = projection.fromLatLngToPoint(sw)!; final int scale = 1 << (zoom.toInt()); // 2 ^ zoom - final gmaps.Point worldPoint = projection.fromLatLngToPoint!(coords)!; + final gmaps.Point worldPoint = projection.fromLatLngToPoint(coords)!; return gmaps.Point( ((worldPoint.x - bottomLeft.x) * scale).toInt(), From 632c425f66745819b4a633b38e9fa3dc74c40386 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 11:55:37 -0400 Subject: [PATCH 04/35] Regenerate mocks --- .../google_maps_controller_test.dart | 32 ++- .../google_maps_controller_test.mocks.dart | 245 +++++++++--------- .../google_maps_plugin_test.mocks.dart | 40 ++- 3 files changed, 182 insertions(+), 135 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index ba0924be8aa..963f42468fd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -21,12 +21,26 @@ import 'google_maps_controller_test.mocks.dart'; // LatLng values. const String _kCloudMapId = '000000000000000'; // Dummy map ID. +class MockMap {} + +gmaps.Map mockMap() => createJSInteropWrapper(MockMap()) as gmaps.Map; + @GenerateNiceMocks(>[ - MockSpec(), - MockSpec(), - MockSpec(), - MockSpec(), - MockSpec(), + MockSpec( + fallbackGenerators: {#googleMap: mockMap}, + ), + MockSpec( + fallbackGenerators: {#googleMap: mockMap}, + ), + MockSpec( + fallbackGenerators: {#googleMap: mockMap}, + ), + MockSpec( + fallbackGenerators: {#googleMap: mockMap}, + ), + MockSpec( + fallbackGenerators: {#googleMap: mockMap}, + ), ]) /// Test Google Map Controller @@ -250,12 +264,16 @@ void main() { gmaps.event.trigger( map, 'click', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, + [ + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0) + ].toJS, ); gmaps.event.trigger( map, 'rightclick', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, + [ + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0) + ].toJS, ); // The following line causes 2 events gmaps.event.trigger(map, 'bounds_changed', [].toJS); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart index aef35cc4046..77d7dd64c7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart @@ -3,14 +3,16 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i5; +import 'dart:async' as _i6; -import 'package:google_maps/google_maps.dart' as _i2; +import 'package:google_maps/google_maps.dart' as _i4; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart' - as _i4; -import 'package:google_maps_flutter_web/google_maps_flutter_web.dart' as _i3; + as _i3; +import 'package:google_maps_flutter_web/google_maps_flutter_web.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; +import 'google_maps_controller_test.dart' as _i5; + // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters @@ -24,52 +26,40 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeGMap_0 extends _i1.SmartFake implements _i2.GMap { - _FakeGMap_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - /// A class which mocks [CirclesController]. /// /// See the documentation for Mockito's code generation for more information. -class MockCirclesController extends _i1.Mock implements _i3.CirclesController { +class MockCirclesController extends _i1.Mock implements _i2.CirclesController { @override - Map<_i4.CircleId, _i3.CircleController> get circles => (super.noSuchMethod( + Map<_i3.CircleId, _i2.CircleController> get circles => (super.noSuchMethod( Invocation.getter(#circles), - returnValue: <_i4.CircleId, _i3.CircleController>{}, - returnValueForMissingStub: <_i4.CircleId, _i3.CircleController>{}, - ) as Map<_i4.CircleId, _i3.CircleController>); + returnValue: <_i3.CircleId, _i2.CircleController>{}, + returnValueForMissingStub: <_i3.CircleId, _i2.CircleController>{}, + ) as Map<_i3.CircleId, _i2.CircleController>); + @override - _i2.GMap get googleMap => (super.noSuchMethod( + _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - returnValueForMissingStub: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - ) as _i2.GMap); + returnValue: _i5.mockMap(), + returnValueForMissingStub: _i5.mockMap(), + ) as _i4.Map); + @override - set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod( + set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( Invocation.setter( #googleMap, _googleMap, ), 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( @@ -78,24 +68,27 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController { ), returnValueForMissingStub: null, ); + @override - void addCircles(Set<_i4.Circle>? circlesToAdd) => super.noSuchMethod( + void addCircles(Set<_i3.Circle>? circlesToAdd) => super.noSuchMethod( Invocation.method( #addCircles, [circlesToAdd], ), returnValueForMissingStub: null, ); + @override - void changeCircles(Set<_i4.Circle>? circlesToChange) => super.noSuchMethod( + void changeCircles(Set<_i3.Circle>? circlesToChange) => super.noSuchMethod( Invocation.method( #changeCircles, [circlesToChange], ), returnValueForMissingStub: null, ); + @override - void removeCircles(Set<_i4.CircleId>? circleIdsToRemove) => + void removeCircles(Set<_i3.CircleId>? circleIdsToRemove) => super.noSuchMethod( Invocation.method( #removeCircles, @@ -103,10 +96,11 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController { ), returnValueForMissingStub: null, ); + @override void bindToMap( int? mapId, - _i2.GMap? googleMap, + _i4.Map? googleMap, ) => super.noSuchMethod( Invocation.method( @@ -124,39 +118,37 @@ class MockCirclesController extends _i1.Mock implements _i3.CirclesController { /// /// See the documentation for Mockito's code generation for more information. class MockPolygonsController extends _i1.Mock - implements _i3.PolygonsController { + implements _i2.PolygonsController { @override - Map<_i4.PolygonId, _i3.PolygonController> get polygons => (super.noSuchMethod( + Map<_i3.PolygonId, _i2.PolygonController> get polygons => (super.noSuchMethod( Invocation.getter(#polygons), - returnValue: <_i4.PolygonId, _i3.PolygonController>{}, - returnValueForMissingStub: <_i4.PolygonId, _i3.PolygonController>{}, - ) as Map<_i4.PolygonId, _i3.PolygonController>); + returnValue: <_i3.PolygonId, _i2.PolygonController>{}, + returnValueForMissingStub: <_i3.PolygonId, _i2.PolygonController>{}, + ) as Map<_i3.PolygonId, _i2.PolygonController>); + @override - _i2.GMap get googleMap => (super.noSuchMethod( + _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - returnValueForMissingStub: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - ) as _i2.GMap); + returnValue: _i5.mockMap(), + returnValueForMissingStub: _i5.mockMap(), + ) as _i4.Map); + @override - set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod( + set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( Invocation.setter( #googleMap, _googleMap, ), 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( @@ -165,24 +157,27 @@ class MockPolygonsController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void addPolygons(Set<_i4.Polygon>? polygonsToAdd) => super.noSuchMethod( + void addPolygons(Set<_i3.Polygon>? polygonsToAdd) => super.noSuchMethod( Invocation.method( #addPolygons, [polygonsToAdd], ), returnValueForMissingStub: null, ); + @override - void changePolygons(Set<_i4.Polygon>? polygonsToChange) => super.noSuchMethod( + void changePolygons(Set<_i3.Polygon>? polygonsToChange) => super.noSuchMethod( Invocation.method( #changePolygons, [polygonsToChange], ), returnValueForMissingStub: null, ); + @override - void removePolygons(Set<_i4.PolygonId>? polygonIdsToRemove) => + void removePolygons(Set<_i3.PolygonId>? polygonIdsToRemove) => super.noSuchMethod( Invocation.method( #removePolygons, @@ -190,10 +185,11 @@ class MockPolygonsController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void bindToMap( int? mapId, - _i2.GMap? googleMap, + _i4.Map? googleMap, ) => super.noSuchMethod( Invocation.method( @@ -211,39 +207,37 @@ class MockPolygonsController extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockPolylinesController extends _i1.Mock - implements _i3.PolylinesController { + implements _i2.PolylinesController { @override - Map<_i4.PolylineId, _i3.PolylineController> get lines => (super.noSuchMethod( + Map<_i3.PolylineId, _i2.PolylineController> get lines => (super.noSuchMethod( Invocation.getter(#lines), - returnValue: <_i4.PolylineId, _i3.PolylineController>{}, - returnValueForMissingStub: <_i4.PolylineId, _i3.PolylineController>{}, - ) as Map<_i4.PolylineId, _i3.PolylineController>); + returnValue: <_i3.PolylineId, _i2.PolylineController>{}, + returnValueForMissingStub: <_i3.PolylineId, _i2.PolylineController>{}, + ) as Map<_i3.PolylineId, _i2.PolylineController>); + @override - _i2.GMap get googleMap => (super.noSuchMethod( + _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - returnValueForMissingStub: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - ) as _i2.GMap); + returnValue: _i5.mockMap(), + returnValueForMissingStub: _i5.mockMap(), + ) as _i4.Map); + @override - set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod( + set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( Invocation.setter( #googleMap, _googleMap, ), 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( @@ -252,16 +246,18 @@ class MockPolylinesController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void addPolylines(Set<_i4.Polyline>? polylinesToAdd) => super.noSuchMethod( + void addPolylines(Set<_i3.Polyline>? polylinesToAdd) => super.noSuchMethod( Invocation.method( #addPolylines, [polylinesToAdd], ), returnValueForMissingStub: null, ); + @override - void changePolylines(Set<_i4.Polyline>? polylinesToChange) => + void changePolylines(Set<_i3.Polyline>? polylinesToChange) => super.noSuchMethod( Invocation.method( #changePolylines, @@ -269,8 +265,9 @@ class MockPolylinesController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void removePolylines(Set<_i4.PolylineId>? polylineIdsToRemove) => + void removePolylines(Set<_i3.PolylineId>? polylineIdsToRemove) => super.noSuchMethod( Invocation.method( #removePolylines, @@ -278,10 +275,11 @@ class MockPolylinesController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void bindToMap( int? mapId, - _i2.GMap? googleMap, + _i4.Map? googleMap, ) => super.noSuchMethod( Invocation.method( @@ -298,39 +296,37 @@ class MockPolylinesController extends _i1.Mock /// A class which mocks [MarkersController]. /// /// See the documentation for Mockito's code generation for more information. -class MockMarkersController extends _i1.Mock implements _i3.MarkersController { +class MockMarkersController extends _i1.Mock implements _i2.MarkersController { @override - Map<_i4.MarkerId, _i3.MarkerController> get markers => (super.noSuchMethod( + Map<_i3.MarkerId, _i2.MarkerController> get markers => (super.noSuchMethod( Invocation.getter(#markers), - returnValue: <_i4.MarkerId, _i3.MarkerController>{}, - returnValueForMissingStub: <_i4.MarkerId, _i3.MarkerController>{}, - ) as Map<_i4.MarkerId, _i3.MarkerController>); + returnValue: <_i3.MarkerId, _i2.MarkerController>{}, + returnValueForMissingStub: <_i3.MarkerId, _i2.MarkerController>{}, + ) as Map<_i3.MarkerId, _i2.MarkerController>); + @override - _i2.GMap get googleMap => (super.noSuchMethod( + _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - returnValueForMissingStub: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - ) as _i2.GMap); + returnValue: _i5.mockMap(), + returnValueForMissingStub: _i5.mockMap(), + ) as _i4.Map); + @override - set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod( + set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( Invocation.setter( #googleMap, _googleMap, ), 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( @@ -339,28 +335,31 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController { ), returnValueForMissingStub: null, ); + @override - _i5.Future addMarkers(Set<_i4.Marker>? markersToAdd) => + _i6.Future addMarkers(Set<_i3.Marker>? markersToAdd) => (super.noSuchMethod( Invocation.method( #addMarkers, [markersToAdd], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override - _i5.Future changeMarkers(Set<_i4.Marker>? markersToChange) => + _i6.Future changeMarkers(Set<_i3.Marker>? markersToChange) => (super.noSuchMethod( Invocation.method( #changeMarkers, [markersToChange], ), - returnValue: _i5.Future.value(), - returnValueForMissingStub: _i5.Future.value(), - ) as _i5.Future); + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override - void removeMarkers(Set<_i4.MarkerId>? markerIdsToRemove) => + void removeMarkers(Set<_i3.MarkerId>? markerIdsToRemove) => super.noSuchMethod( Invocation.method( #removeMarkers, @@ -368,24 +367,27 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController { ), returnValueForMissingStub: null, ); + @override - void showMarkerInfoWindow(_i4.MarkerId? markerId) => super.noSuchMethod( + void showMarkerInfoWindow(_i3.MarkerId? markerId) => super.noSuchMethod( Invocation.method( #showMarkerInfoWindow, [markerId], ), returnValueForMissingStub: null, ); + @override - void hideMarkerInfoWindow(_i4.MarkerId? markerId) => super.noSuchMethod( + void hideMarkerInfoWindow(_i3.MarkerId? markerId) => super.noSuchMethod( Invocation.method( #hideMarkerInfoWindow, [markerId], ), returnValueForMissingStub: null, ); + @override - bool isInfoWindowShown(_i4.MarkerId? markerId) => (super.noSuchMethod( + bool isInfoWindowShown(_i3.MarkerId? markerId) => (super.noSuchMethod( Invocation.method( #isInfoWindowShown, [markerId], @@ -393,10 +395,11 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController { returnValue: false, returnValueForMissingStub: false, ) as bool); + @override void bindToMap( int? mapId, - _i2.GMap? googleMap, + _i4.Map? googleMap, ) => super.noSuchMethod( Invocation.method( @@ -414,33 +417,30 @@ class MockMarkersController extends _i1.Mock implements _i3.MarkersController { /// /// See the documentation for Mockito's code generation for more information. class MockTileOverlaysController extends _i1.Mock - implements _i3.TileOverlaysController { + implements _i2.TileOverlaysController { @override - _i2.GMap get googleMap => (super.noSuchMethod( + _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - returnValueForMissingStub: _FakeGMap_0( - this, - Invocation.getter(#googleMap), - ), - ) as _i2.GMap); + returnValue: _i5.mockMap(), + returnValueForMissingStub: _i5.mockMap(), + ) as _i4.Map); + @override - set googleMap(_i2.GMap? _googleMap) => super.noSuchMethod( + set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( Invocation.setter( #googleMap, _googleMap, ), 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( @@ -449,8 +449,9 @@ class MockTileOverlaysController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void addTileOverlays(Set<_i4.TileOverlay>? tileOverlaysToAdd) => + void addTileOverlays(Set<_i3.TileOverlay>? tileOverlaysToAdd) => super.noSuchMethod( Invocation.method( #addTileOverlays, @@ -458,8 +459,9 @@ class MockTileOverlaysController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void changeTileOverlays(Set<_i4.TileOverlay>? tileOverlays) => + void changeTileOverlays(Set<_i3.TileOverlay>? tileOverlays) => super.noSuchMethod( Invocation.method( #changeTileOverlays, @@ -467,8 +469,9 @@ class MockTileOverlaysController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void removeTileOverlays(Set<_i4.TileOverlayId>? tileOverlayIds) => + void removeTileOverlays(Set<_i3.TileOverlayId>? tileOverlayIds) => super.noSuchMethod( Invocation.method( #removeTileOverlays, @@ -476,18 +479,20 @@ class MockTileOverlaysController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override - void clearTileCache(_i4.TileOverlayId? tileOverlayId) => super.noSuchMethod( + void clearTileCache(_i3.TileOverlayId? tileOverlayId) => super.noSuchMethod( Invocation.method( #clearTileCache, [tileOverlayId], ), returnValueForMissingStub: null, ); + @override void bindToMap( int? mapId, - _i2.GMap? googleMap, + _i4.Map? googleMap, ) => super.noSuchMethod( Invocation.method( diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart index 30d7b46859e..2da0a46f13f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart @@ -95,37 +95,42 @@ class MockGoogleMapController extends _i1.Mock Invocation.getter(#configuration), ), ) as _i2.MapConfiguration); + @override - _i3.StreamController<_i2.MapEvent> get stream => (super.noSuchMethod( + _i3.StreamController<_i2.MapEvent> get stream => (super.noSuchMethod( Invocation.getter(#stream), - returnValue: _FakeStreamController_1<_i2.MapEvent>( + returnValue: _FakeStreamController_1<_i2.MapEvent>( this, Invocation.getter(#stream), ), returnValueForMissingStub: - _FakeStreamController_1<_i2.MapEvent>( + _FakeStreamController_1<_i2.MapEvent>( this, Invocation.getter(#stream), ), - ) as _i3.StreamController<_i2.MapEvent>); + ) as _i3.StreamController<_i2.MapEvent>); + @override - _i3.Stream<_i2.MapEvent> get events => (super.noSuchMethod( + _i3.Stream<_i2.MapEvent> get events => (super.noSuchMethod( Invocation.getter(#events), - returnValue: _i3.Stream<_i2.MapEvent>.empty(), - returnValueForMissingStub: _i3.Stream<_i2.MapEvent>.empty(), - ) as _i3.Stream<_i2.MapEvent>); + returnValue: _i3.Stream<_i2.MapEvent>.empty(), + returnValueForMissingStub: _i3.Stream<_i2.MapEvent>.empty(), + ) as _i3.Stream<_i2.MapEvent>); + @override bool get isInitialized => (super.noSuchMethod( Invocation.getter(#isInitialized), returnValue: false, returnValueForMissingStub: false, ) as bool); + @override List<_i5.MapTypeStyle> get styles => (super.noSuchMethod( Invocation.getter(#styles), returnValue: <_i5.MapTypeStyle>[], returnValueForMissingStub: <_i5.MapTypeStyle>[], ) as List<_i5.MapTypeStyle>); + @override void debugSetOverrides({ _i4.DebugCreateMapFunction? createMap, @@ -154,6 +159,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void init() => super.noSuchMethod( Invocation.method( @@ -162,6 +168,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void updateMapConfiguration(_i2.MapConfiguration? update) => super.noSuchMethod( @@ -171,6 +178,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void updateStyles(List<_i5.MapTypeStyle>? styles) => super.noSuchMethod( Invocation.method( @@ -179,6 +187,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i3.Future<_i2.LatLngBounds> getVisibleRegion() => (super.noSuchMethod( Invocation.method( @@ -201,6 +210,7 @@ class MockGoogleMapController extends _i1.Mock ), )), ) as _i3.Future<_i2.LatLngBounds>); + @override _i3.Future<_i2.ScreenCoordinate> getScreenCoordinate(_i2.LatLng? latLng) => (super.noSuchMethod( @@ -225,6 +235,7 @@ class MockGoogleMapController extends _i1.Mock ), )), ) as _i3.Future<_i2.ScreenCoordinate>); + @override _i3.Future<_i2.LatLng> getLatLng(_i2.ScreenCoordinate? screenCoordinate) => (super.noSuchMethod( @@ -247,6 +258,7 @@ class MockGoogleMapController extends _i1.Mock ), )), ) as _i3.Future<_i2.LatLng>); + @override _i3.Future moveCamera(_i2.CameraUpdate? cameraUpdate) => (super.noSuchMethod( @@ -257,6 +269,7 @@ class MockGoogleMapController extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override _i3.Future getZoomLevel() => (super.noSuchMethod( Invocation.method( @@ -266,6 +279,7 @@ class MockGoogleMapController extends _i1.Mock returnValue: _i3.Future.value(0.0), returnValueForMissingStub: _i3.Future.value(0.0), ) as _i3.Future); + @override void updateCircles(_i2.CircleUpdates? updates) => super.noSuchMethod( Invocation.method( @@ -274,6 +288,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void updatePolygons(_i2.PolygonUpdates? updates) => super.noSuchMethod( Invocation.method( @@ -282,6 +297,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void updatePolylines(_i2.PolylineUpdates? updates) => super.noSuchMethod( Invocation.method( @@ -290,6 +306,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override _i3.Future updateMarkers(_i2.MarkerUpdates? updates) => (super.noSuchMethod( @@ -300,6 +317,7 @@ class MockGoogleMapController extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); + @override void updateClusterManagers(_i2.ClusterManagerUpdates? updates) => super.noSuchMethod( @@ -309,6 +327,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void updateTileOverlays(Set<_i2.TileOverlay>? newOverlays) => super.noSuchMethod( @@ -318,6 +337,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void clearTileCache(_i2.TileOverlayId? id) => super.noSuchMethod( Invocation.method( @@ -326,6 +346,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void showInfoWindow(_i2.MarkerId? markerId) => super.noSuchMethod( Invocation.method( @@ -334,6 +355,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void hideInfoWindow(_i2.MarkerId? markerId) => super.noSuchMethod( Invocation.method( @@ -342,6 +364,7 @@ class MockGoogleMapController extends _i1.Mock ), returnValueForMissingStub: null, ); + @override bool isInfoWindowShown(_i2.MarkerId? markerId) => (super.noSuchMethod( Invocation.method( @@ -351,6 +374,7 @@ class MockGoogleMapController extends _i1.Mock returnValue: false, returnValueForMissingStub: false, ) as bool); + @override void dispose() => super.noSuchMethod( Invocation.method( From 6549ae9a3a310254f01db7a5cbda5d7cbeea2cc6 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 12:51:12 -0400 Subject: [PATCH 05/35] Fixing issues --- .../integration_test/google_maps_controller_test.dart | 2 +- .../google_maps_flutter_web/lib/src/convert.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index 963f42468fd..3ef9120dbe8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -23,7 +23,7 @@ const String _kCloudMapId = '000000000000000'; // Dummy map ID. class MockMap {} -gmaps.Map mockMap() => createJSInteropWrapper(MockMap()) as gmaps.Map; +gmaps.Map mockMap() => throw UnimplementedError(); @GenerateNiceMocks(>[ MockSpec( diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index d1ee29762de..f0e7b979c24 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -198,9 +198,9 @@ LatLngBounds gmLatLngBoundsTolatLngBounds(gmaps.LatLngBounds latLngBounds) { CameraPosition _gmViewportToCameraPosition(gmaps.Map map) { return CameraPosition( target: gmLatLngToLatLng(map.center), - bearing: map.heading.toDouble() , - tilt: map.tilt.toDouble(), - zoom: map.zoom.toDouble(), + bearing: map.isHeadingDefined() ? map.heading.toDouble() : 0, + tilt: map.isTiltDefined() ? map.tilt.toDouble() : 0, + zoom: map.isZoomDefined() ? map.zoom.toDouble() : 0, ); } From 662a656685dc2dacee15af14d0e7463336a46c1e Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 13:09:31 -0400 Subject: [PATCH 06/35] Fixing issues --- .../google_maps_controller_test.dart | 12 ++++-------- .../google_maps_flutter_web/lib/src/convert.dart | 3 ++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index 3ef9120dbe8..9881509379b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -264,20 +264,16 @@ void main() { gmaps.event.trigger( map, 'click', - [ - gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0) - ].toJS, + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), ); gmaps.event.trigger( map, 'rightclick', - [ - gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0) - ].toJS, + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), ); // The following line causes 2 events - gmaps.event.trigger(map, 'bounds_changed', [].toJS); - gmaps.event.trigger(map, 'idle', [].toJS); + gmaps.event.trigger(map, 'bounds_changed'); + gmaps.event.trigger(map, 'idle'); final List> events = await capturedEvents.toList(); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index f0e7b979c24..3b9491557b3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -197,7 +197,8 @@ LatLngBounds gmLatLngBoundsTolatLngBounds(gmaps.LatLngBounds latLngBounds) { CameraPosition _gmViewportToCameraPosition(gmaps.Map map) { return CameraPosition( - target: gmLatLngToLatLng(map.center), + target: + gmLatLngToLatLng(map.isCenterDefined() ? map.center : _nullGmapsLatLng), bearing: map.isHeadingDefined() ? map.heading.toDouble() : 0, tilt: map.isTiltDefined() ? map.tilt.toDouble() : 0, zoom: map.isZoomDefined() ? map.zoom.toDouble() : 0, From 009bde112924224345b3ec0c5323b4cc049b9c34 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 13:41:36 -0400 Subject: [PATCH 07/35] Fixing issues --- .../google_maps_controller_test.dart | 15 ++++++-------- .../google_maps_controller_test.mocks.dart | 20 +++++++++---------- .../example/integration_test/marker_test.dart | 2 +- .../example/integration_test/shape_test.dart | 6 +++--- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index 9881509379b..7a735062c38 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:js_interop'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -21,25 +20,23 @@ import 'google_maps_controller_test.mocks.dart'; // LatLng values. const String _kCloudMapId = '000000000000000'; // Dummy map ID. -class MockMap {} - -gmaps.Map mockMap() => throw UnimplementedError(); +gmaps.Map mapShim() => throw UnimplementedError(); @GenerateNiceMocks(>[ MockSpec( - fallbackGenerators: {#googleMap: mockMap}, + fallbackGenerators: {#googleMap: mapShim}, ), MockSpec( - fallbackGenerators: {#googleMap: mockMap}, + fallbackGenerators: {#googleMap: mapShim}, ), MockSpec( - fallbackGenerators: {#googleMap: mockMap}, + fallbackGenerators: {#googleMap: mapShim}, ), MockSpec( - fallbackGenerators: {#googleMap: mockMap}, + fallbackGenerators: {#googleMap: mapShim}, ), MockSpec( - fallbackGenerators: {#googleMap: mockMap}, + fallbackGenerators: {#googleMap: mapShim}, ), ]) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart index 77d7dd64c7a..832b799724e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart @@ -40,8 +40,8 @@ class MockCirclesController extends _i1.Mock implements _i2.CirclesController { @override _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _i5.mockMap(), - returnValueForMissingStub: _i5.mockMap(), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), ) as _i4.Map); @override @@ -129,8 +129,8 @@ class MockPolygonsController extends _i1.Mock @override _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _i5.mockMap(), - returnValueForMissingStub: _i5.mockMap(), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), ) as _i4.Map); @override @@ -218,8 +218,8 @@ class MockPolylinesController extends _i1.Mock @override _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _i5.mockMap(), - returnValueForMissingStub: _i5.mockMap(), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), ) as _i4.Map); @override @@ -307,8 +307,8 @@ class MockMarkersController extends _i1.Mock implements _i2.MarkersController { @override _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _i5.mockMap(), - returnValueForMissingStub: _i5.mockMap(), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), ) as _i4.Map); @override @@ -421,8 +421,8 @@ class MockTileOverlaysController extends _i1.Mock @override _i4.Map get googleMap => (super.noSuchMethod( Invocation.getter(#googleMap), - returnValue: _i5.mockMap(), - returnValueForMissingStub: _i5.mockMap(), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), ) as _i4.Map); @override diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 6223493417f..63dd54066ca 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -108,7 +108,7 @@ void main() { ..draggable = true ..position = gmaps.LatLng(42, 54); - expect(marker.draggable, isNull); + expect(marker.isDraggableDefined(), isFalse); controller.update(options); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart index 73c8481ae3b..257a07be529 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart @@ -54,7 +54,7 @@ void main() { final gmaps.CircleOptions options = gmaps.CircleOptions() ..draggable = true; - expect(circle.draggable, isNull); + expect(circle.isDraggableDefined(), isFalse); controller.update(options); @@ -110,7 +110,7 @@ void main() { final gmaps.PolygonOptions options = gmaps.PolygonOptions() ..draggable = true; - expect(polygon.draggable, isNull); + expect(polygon.isDraggableDefined(), isFalse); controller.update(options); @@ -172,7 +172,7 @@ void main() { final gmaps.PolylineOptions options = gmaps.PolylineOptions() ..draggable = true; - expect(polyline.draggable, isNull); + expect(polyline.isDraggableDefined(), isFalse); controller.update(options); From 9d3b749016002965f2c6cc24fa9edc03ed6e1df1 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 14:00:17 -0400 Subject: [PATCH 08/35] Update index.html files --- .../example/web/index.html | 23 +------------------ .../example/web/index.html | 2 +- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/web/index.html b/packages/google_maps_flutter/google_maps_flutter/example/web/index.html index 58522ba720c..740c29cd032 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/web/index.html +++ b/packages/google_maps_flutter/google_maps_flutter/example/web/index.html @@ -33,34 +33,13 @@ Google Maps Web Example - - - - - + diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html b/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html index 9cbd7be791d..4d058d79cc5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html @@ -10,6 +10,6 @@ - + From c886e306ce9ac39bcb007f9cce6870cd1abd3879 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 14:18:27 -0400 Subject: [PATCH 09/35] Use google_maps from git for now --- .../google_maps_flutter_web/example/pubspec.yaml | 4 ++++ .../google_maps_flutter_web/pubspec.yaml | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 75e8aeee204..62a7cb2ee5c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -35,3 +35,7 @@ dependency_overrides: # if we need to make a breaking change to google_maps_flutter_web. google_maps_flutter_web: path: ../ + google_maps: + git: + url: https://github.com/Rexios80/dart-google-maps + ref: 0e156160a6d3e6d9b8b7f26603d4f825029c217f diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 5f170f73414..946f473c850 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -32,6 +32,12 @@ dev_dependencies: flutter_test: sdk: flutter +dependency_overrides: + google_maps: + git: + url: https://github.com/Rexios80/dart-google-maps + ref: 0e156160a6d3e6d9b8b7f26603d4f825029c217f + topics: - google-maps - google-maps-flutter From f630e78a2d020e721a5ae034ef19f6169d6cd18a Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 14:29:37 -0400 Subject: [PATCH 10/35] Cleanup --- .../example/integration_test/marker_test.dart | 18 ++++++++++++++---- .../example/integration_test/overlay_test.dart | 15 ++++++--------- .../example/integration_test/shape_test.dart | 18 +++++++++++++++--- .../example/pubspec.yaml | 8 ++++---- .../lib/src/convert.dart | 2 +- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 63dd54066ca..39809e5528d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -57,7 +57,11 @@ void main() { MarkerController(marker: marker, onTap: onTap); // Trigger a click event... - gmaps.event.trigger(marker, 'click', [gmaps.MapMouseEvent()].toJS); + gmaps.event.trigger( + marker, + 'click', + [gmaps.MapMouseEvent()].toJS, + ); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -70,7 +74,9 @@ void main() { gmaps.event.trigger( marker, 'dragstart', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, + [ + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), + ].toJS, ); expect(await methodCalled, isTrue); @@ -83,7 +89,9 @@ void main() { gmaps.event.trigger( marker, 'drag', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, + [ + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), + ].toJS, ); expect(await methodCalled, isTrue); @@ -96,7 +104,9 @@ void main() { gmaps.event.trigger( marker, 'dragend', - [gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0)].toJS, + [ + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), + ].toJS, ); expect(await methodCalled, isTrue); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart index 39b840eaa21..26ba81bcd17 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart @@ -58,9 +58,8 @@ void main() { ), ); - final HTMLImageElement img = - controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! - as HTMLImageElement; + final HTMLImageElement img = controller.gmMapType + .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; expect(img.naturalWidth, 0); expect(img.naturalHeight, 0); expect(img.hidden, true); @@ -82,9 +81,8 @@ void main() { ), ); { - final HTMLImageElement img = - controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! - as HTMLImageElement; + final HTMLImageElement img = controller.gmMapType + .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; await null; // let `getTile` `then` complete expect( img.src, @@ -98,9 +96,8 @@ void main() { tileProvider: TestTileProvider(), )); { - final HTMLImageElement img = - controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! - as HTMLImageElement; + final HTMLImageElement img = controller.gmMapType + .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; await img.onLoad.first; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart index 257a07be529..3c4d9f4c9a7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart @@ -43,7 +43,11 @@ void main() { CircleController(circle: circle, consumeTapEvents: true, onTap: onTap); // Trigger a click event... - gmaps.event.trigger(circle, 'click', [gmaps.MapMouseEvent()].toJS); + gmaps.event.trigger( + circle, + 'click', + [gmaps.MapMouseEvent()].toJS, + ); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -99,7 +103,11 @@ void main() { PolygonController(polygon: polygon, consumeTapEvents: true, onTap: onTap); // Trigger a click event... - gmaps.event.trigger(polygon, 'click', [gmaps.MapMouseEvent()].toJS); + gmaps.event.trigger( + polygon, + 'click', + [gmaps.MapMouseEvent()].toJS, + ); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -159,7 +167,11 @@ void main() { ); // Trigger a click event... - gmaps.event.trigger(polyline, 'click', [gmaps.MapMouseEvent()].toJS); + gmaps.event.trigger( + polyline, + 'click', + [gmaps.MapMouseEvent()].toJS, + ); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 62a7cb2ee5c..1f36003ae15 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -30,12 +30,12 @@ flutter: - assets/ dependency_overrides: + google_maps: + git: + url: https://github.com/Rexios80/dart-google-maps + ref: 0e156160a6d3e6d9b8b7f26603d4f825029c217f # Override the google_maps_flutter dependency on google_maps_flutter_web. # TODO(ditman): Unwind the circular dependency. This will create problems # if we need to make a breaking change to google_maps_flutter_web. google_maps_flutter_web: path: ../ - google_maps: - git: - url: https://github.com/Rexios80/dart-google-maps - ref: 0e156160a6d3e6d9b8b7f26603d4f825029c217f diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 3b9491557b3..1eb29419a79 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -497,7 +497,7 @@ gmaps.PolygonOptions _polygonOptionsFromPolygon( } return gmaps.PolygonOptions() - ..paths = paths.map((e) => e.toJS).toList().toJS + ..paths = paths.map((List e) => e.toJS).toList().toJS ..strokeColor = _getCssColor(polygon.strokeColor) ..strokeOpacity = _getCssOpacity(polygon.strokeColor) ..strokeWeight = polygon.strokeWidth From 8ed05670d16a2fb62f8bdc8189bcfe5b2fda8fb2 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 14:32:58 -0400 Subject: [PATCH 11/35] Cleanup --- .../google_maps_flutter_web/example/pubspec.yaml | 2 +- .../google_maps_flutter_web/lib/src/convert.dart | 11 +++++++---- .../lib/src/google_maps_controller.dart | 5 ++++- .../to_screen_location/to_screen_location.dart | 5 ++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 1f36003ae15..82a6a158114 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -20,7 +20,7 @@ dev_dependencies: sdk: flutter google_maps: ^8.0.0-dev.1 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart - http: ^1.0.0 + http: ">=0.13.0 <2.0.0" integration_test: sdk: flutter mockito: 5.4.4 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 1eb29419a79..0032cf5a417 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -632,14 +632,14 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { // print('Error computing new focus LatLng. JS Error: ' + e.toString()); } } - map.zoom = (map.zoom) + newZoomDelta; + map.zoom = (map.isZoomDefined() ? map.zoom : 0) + newZoomDelta; if (focusLatLng != null) { map.panTo(focusLatLng); } case 'zoomIn': - map.zoom = (map.zoom) + 1; + map.zoom = (map.isZoomDefined() ? map.zoom : 0) + 1; case 'zoomOut': - map.zoom = (map.zoom) - 1; + map.zoom = (map.isZoomDefined() ? map.zoom : 0) - 1; case 'zoomTo': map.zoom = json[1]! as num; default: @@ -651,12 +651,15 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final gmaps.LatLngBounds? bounds = map.bounds; final gmaps.Projection? projection = map.projection; - final num zoom = map.zoom; assert( bounds != null, 'Map Bounds required to compute LatLng of screen x/y.'); assert(projection != null, 'Map Projection required to compute LatLng of screen x/y'); + assert(map.isZoomDefined(), + 'Current map zoom level required to compute LatLng of screen x/y'); + + final num zoom = map.zoom; final gmaps.LatLng ne = bounds!.northEast; final gmaps.LatLng sw = bounds.southWest; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 59dafe485a5..21ebcd0369f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -428,7 +428,10 @@ class GoogleMapController { /// Returns the zoom level of the current viewport. Future getZoomLevel() async { assert(_googleMap != null, 'Cannot get zoom level of a null map.'); - return _googleMap!.zoom.toDouble(); + assert(_googleMap!.isZoomDefined(), + 'Zoom level should not be null. Is the map correctly initialized?'); + + return _googleMap!.zoom!.toDouble(); } // Geometry manipulation diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart index ca031e3fd3a..ead29d4fcb0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart @@ -29,7 +29,6 @@ import 'package:google_maps/google_maps.dart' as gmaps; /// /// See: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/Projection#public-point-toscreenlocation-latlng-location gmaps.Point toScreenLocation(gmaps.Map map, gmaps.LatLng coords) { - final num zoom = map.zoom; final gmaps.LatLngBounds? bounds = map.bounds; final gmaps.Projection? projection = map.projection; @@ -37,6 +36,10 @@ gmaps.Point toScreenLocation(gmaps.Map map, gmaps.LatLng coords) { bounds != null, 'Map Bounds required to compute screen x/y of LatLng.'); assert(projection != null, 'Map Projection required to compute screen x/y of LatLng.'); + assert(map.isZoomDefined(), + 'Current map zoom level required to compute screen x/y of LatLng.'); + + final num zoom = map.zoom; final gmaps.LatLng ne = bounds!.northEast; final gmaps.LatLng sw = bounds.southWest; From 8365be55d1abb64e7c0315794fe1ee148b1acfe0 Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 14:37:45 -0400 Subject: [PATCH 12/35] Fixing issues --- .../google_maps_flutter_web/lib/src/google_maps_controller.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 21ebcd0369f..3baeef8851a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -431,7 +431,7 @@ class GoogleMapController { assert(_googleMap!.isZoomDefined(), 'Zoom level should not be null. Is the map correctly initialized?'); - return _googleMap!.zoom!.toDouble(); + return _googleMap!.zoom.toDouble(); } // Geometry manipulation From 11367188f84046b1641242d699a06a914176d54e Mon Sep 17 00:00:00 2001 From: Rexios Date: Mon, 8 Jul 2024 15:25:26 -0400 Subject: [PATCH 13/35] Preparing for release --- .../google_maps_flutter/google_maps_flutter_web/CHANGELOG.md | 4 ++++ .../google_maps_flutter/google_maps_flutter_web/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index a519cfc7ada..58b859eac34 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -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`. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 946f473c850..61187598308 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_web description: Web platform implementation of google_maps_flutter repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 0.5.8 +version: 0.5.9 environment: sdk: ^3.3.0 From 4596476281145c27fc6651f5b2c7f846d15d3262 Mon Sep 17 00:00:00 2001 From: Rexios Date: Tue, 9 Jul 2024 08:33:53 -0400 Subject: [PATCH 14/35] Use latest google_maps commit --- .../google_maps_flutter_web/example/pubspec.yaml | 4 ++-- .../google_maps_flutter/google_maps_flutter_web/pubspec.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 82a6a158114..61a99a8ce4a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -32,8 +32,8 @@ flutter: dependency_overrides: google_maps: git: - url: https://github.com/Rexios80/dart-google-maps - ref: 0e156160a6d3e6d9b8b7f26603d4f825029c217f + url: https://github.com/a14n/dart-google-maps + ref: 5972ce588c6505fa73b783ca2be68272b5e6f2da # Override the google_maps_flutter dependency on google_maps_flutter_web. # TODO(ditman): Unwind the circular dependency. This will create problems # if we need to make a breaking change to google_maps_flutter_web. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 61187598308..753ef908718 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -35,8 +35,8 @@ dev_dependencies: dependency_overrides: google_maps: git: - url: https://github.com/Rexios80/dart-google-maps - ref: 0e156160a6d3e6d9b8b7f26603d4f825029c217f + url: https://github.com/a14n/dart-google-maps + ref: 5972ce588c6505fa73b783ca2be68272b5e6f2da topics: - google-maps From b417e89a59623854e7885438459f46e22acc1e19 Mon Sep 17 00:00:00 2001 From: Rexios Date: Wed, 10 Jul 2024 15:35:07 -0400 Subject: [PATCH 15/35] Use latest google_maps commit --- .../google_maps_flutter_web/example/pubspec.yaml | 2 +- .../google_maps_flutter/google_maps_flutter_web/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 61a99a8ce4a..e6608cd3b05 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -33,7 +33,7 @@ dependency_overrides: google_maps: git: url: https://github.com/a14n/dart-google-maps - ref: 5972ce588c6505fa73b783ca2be68272b5e6f2da + ref: 0f57b7d99ed9652a31cd60a5dd4f3c6cb6b9f31a # Override the google_maps_flutter dependency on google_maps_flutter_web. # TODO(ditman): Unwind the circular dependency. This will create problems # if we need to make a breaking change to google_maps_flutter_web. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 753ef908718..fe230f51d09 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -36,7 +36,7 @@ dependency_overrides: google_maps: git: url: https://github.com/a14n/dart-google-maps - ref: 5972ce588c6505fa73b783ca2be68272b5e6f2da + ref: 0f57b7d99ed9652a31cd60a5dd4f3c6cb6b9f31a topics: - google-maps From a6562b10e724bb5d97c5d490ee145afb5401ce13 Mon Sep 17 00:00:00 2001 From: Rexios Date: Thu, 11 Jul 2024 16:36:22 -0400 Subject: [PATCH 16/35] Update exclude_all_packages_app_wasm.yaml --- script/configs/exclude_all_packages_app_wasm.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/script/configs/exclude_all_packages_app_wasm.yaml b/script/configs/exclude_all_packages_app_wasm.yaml index d10cdbf6ff2..e2596d37d4e 100644 --- a/script/configs/exclude_all_packages_app_wasm.yaml +++ b/script/configs/exclude_all_packages_app_wasm.yaml @@ -9,7 +9,3 @@ # https://github.com/flutter/flutter/issues/117022 - camera - webview_flutter - -# Dependencies are not migrated yet -# https://github.com/flutter/flutter/issues/148624 -- google_maps_flutter From e763d9d1308831f4f67e03a5ce621c6b19c8aebd Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 12 Jul 2024 20:10:44 -0400 Subject: [PATCH 17/35] Add `google_maps` dependency override to `google_maps_flutter` temporarily --- .../google_maps_flutter/google_maps_flutter/pubspec.yaml | 7 +++++++ .../google_maps_flutter_web/example/pubspec.yaml | 1 + .../google_maps_flutter_web/pubspec.yaml | 1 + 3 files changed, 9 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 3ab5430b095..9a851c1c2c7 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -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 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index e6608cd3b05..78535333145 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -30,6 +30,7 @@ flutter: - assets/ dependency_overrides: + # FOR TESTING ONLY. DO NOT MERGE. google_maps: git: url: https://github.com/a14n/dart-google-maps diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index fe230f51d09..ce1a3f87f0c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -32,6 +32,7 @@ dev_dependencies: flutter_test: sdk: flutter +# FOR TESTING ONLY. DO NOT MERGE. dependency_overrides: google_maps: git: From 8468c5297032937c9c1d3627e8cdc4f475e011db Mon Sep 17 00:00:00 2001 From: Rexios Date: Tue, 23 Jul 2024 15:53:50 -0400 Subject: [PATCH 18/35] Use new `google_maps` version and remove overrides --- .../google_maps_flutter/google_maps_flutter/pubspec.yaml | 7 ------- .../google_maps_flutter_web/example/pubspec.yaml | 7 +------ .../google_maps_flutter_web/pubspec.yaml | 9 +-------- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 9a851c1c2c7..3ab5430b095 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -32,13 +32,6 @@ 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 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 78535333145..4b2062bffe2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -18,7 +18,7 @@ dev_dependencies: build_runner: ^2.1.1 flutter_test: sdk: flutter - google_maps: ^8.0.0-dev.1 + google_maps: ^8.0.0-dev.2 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart http: ">=0.13.0 <2.0.0" integration_test: @@ -30,11 +30,6 @@ flutter: - assets/ dependency_overrides: - # FOR TESTING ONLY. DO NOT MERGE. - google_maps: - git: - url: https://github.com/a14n/dart-google-maps - ref: 0f57b7d99ed9652a31cd60a5dd4f3c6cb6b9f31a # Override the google_maps_flutter dependency on google_maps_flutter_web. # TODO(ditman): Unwind the circular dependency. This will create problems # if we need to make a breaking change to google_maps_flutter_web. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index ce1a3f87f0c..55d663b4148 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - google_maps: ^8.0.0-dev.1 + google_maps: ^8.0.0-dev.2 google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 @@ -32,13 +32,6 @@ dev_dependencies: flutter_test: sdk: flutter -# 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 From 78df83dc4c8c65df78c1d7de4c431ecfb4405dd2 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 23 Jul 2024 19:19:58 -0700 Subject: [PATCH 19/35] Trigger events the same way as in google_maps_controller_test --- .../example/integration_test/marker_test.dart | 15 ++++----------- .../example/integration_test/shape_test.dart | 7 +++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 39809e5528d..2859d082b78 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:js_interop'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_maps/google_maps.dart' as gmaps; @@ -60,7 +59,7 @@ void main() { gmaps.event.trigger( marker, 'click', - [gmaps.MapMouseEvent()].toJS, + gmaps.MapMouseEvent(), ); // The event handling is now truly async. Wait for it... @@ -74,9 +73,7 @@ void main() { gmaps.event.trigger( marker, 'dragstart', - [ - gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), - ].toJS, + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), ); expect(await methodCalled, isTrue); @@ -89,9 +86,7 @@ void main() { gmaps.event.trigger( marker, 'drag', - [ - gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), - ].toJS, + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), ); expect(await methodCalled, isTrue); @@ -104,9 +99,7 @@ void main() { gmaps.event.trigger( marker, 'dragend', - [ - gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), - ].toJS, + gmaps.MapMouseEvent()..latLng = gmaps.LatLng(0, 0), ); expect(await methodCalled, isTrue); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart index 3c4d9f4c9a7..b8da855de84 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:js_interop'; import 'package:flutter_test/flutter_test.dart'; import 'package:google_maps/google_maps.dart' as gmaps; @@ -46,7 +45,7 @@ void main() { gmaps.event.trigger( circle, 'click', - [gmaps.MapMouseEvent()].toJS, + gmaps.MapMouseEvent(), ); // The event handling is now truly async. Wait for it... @@ -106,7 +105,7 @@ void main() { gmaps.event.trigger( polygon, 'click', - [gmaps.MapMouseEvent()].toJS, + gmaps.MapMouseEvent(), ); // The event handling is now truly async. Wait for it... @@ -170,7 +169,7 @@ void main() { gmaps.event.trigger( polyline, 'click', - [gmaps.MapMouseEvent()].toJS, + gmaps.MapMouseEvent(), ); // The event handling is now truly async. Wait for it... From ef431665b7a9cf896d48542d42879bace5176a38 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 23 Jul 2024 20:18:20 -0700 Subject: [PATCH 20/35] Run assertions before accessing bounds and projection. --- .../to_screen_location/to_screen_location.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart index ead29d4fcb0..fc206eb6f91 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart @@ -29,22 +29,21 @@ import 'package:google_maps/google_maps.dart' as gmaps; /// /// See: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/Projection#public-point-toscreenlocation-latlng-location gmaps.Point toScreenLocation(gmaps.Map map, gmaps.LatLng coords) { - final gmaps.LatLngBounds? bounds = map.bounds; - final gmaps.Projection? projection = map.projection; - - assert( - bounds != null, 'Map Bounds required to compute screen x/y of LatLng.'); - assert(projection != null, + assert(map.bounds != null, + 'Map Bounds required to compute screen x/y of LatLng.'); + assert(map.projection != null, 'Map Projection required to compute screen x/y of LatLng.'); assert(map.isZoomDefined(), 'Current map zoom level required to compute screen x/y of LatLng.'); + final gmaps.LatLngBounds bounds = map.bounds!; + final gmaps.Projection projection = map.projection!; final num zoom = map.zoom; - final gmaps.LatLng ne = bounds!.northEast; + final gmaps.LatLng ne = bounds.northEast; final gmaps.LatLng sw = bounds.southWest; - final gmaps.Point topRight = projection!.fromLatLngToPoint(ne)!; + final gmaps.Point topRight = projection.fromLatLngToPoint(ne)!; final gmaps.Point bottomLeft = projection.fromLatLngToPoint(sw)!; final int scale = 1 << (zoom.toInt()); // 2 ^ zoom From c04ae2252ef5d4f8865bd25fa7fc8472149c5e03 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 23 Jul 2024 20:19:28 -0700 Subject: [PATCH 21/35] Allow web:^1.0.0 Update deps, a small bit of convert code and CHANGELOG. --- .../google_maps_flutter_web/CHANGELOG.md | 2 ++ .../google_maps_flutter_web/example/pubspec.yaml | 14 ++++++++------ .../google_maps_flutter_web/lib/src/convert.dart | 2 +- .../google_maps_flutter_web/pubspec.yaml | 11 +++++++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 58b859eac34..8e6e1498247 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,6 +1,8 @@ # 0.5.9 * Updates `package:google_maps` dependency to latest (`^8.0.0`). +* Updates web code to allow package `web: ^1.0.0`. +* Updates SDK version to Dart `^3.4.0`. Flutter `^3.22.0`. ## 0.5.8 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 4b2062bffe2..6d9926b2db5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -1,10 +1,9 @@ name: google_maps_flutter_web_integration_tests publish_to: none -# Tests require flutter beta or greater to run. environment: - sdk: ^3.3.0 - flutter: ">=3.19.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" dependencies: flutter: @@ -12,15 +11,18 @@ dependencies: google_maps_flutter_platform_interface: ^2.7.0 google_maps_flutter_web: path: ../ - web: ^0.5.0 + web: ^1.0.0 dev_dependencies: build_runner: ^2.1.1 flutter_test: sdk: flutter - google_maps: ^8.0.0-dev.2 + google_maps: #^8.0.0-dev.3 + git: + url: git@github.com:ditman/a14n-dart-google-maps.git + ref: allow-web-1 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart - http: ">=0.13.0 <2.0.0" + http: ^1.2.2 integration_test: sdk: flutter mockito: 5.4.4 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 0032cf5a417..1a9819684b9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -254,7 +254,7 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { // See: https://pub.dev/documentation/sanitize_html/latest/sanitize_html/sanitizeHtml.html // See: b/159137885, b/159598165 // ignore: unsafe_html - snippet.innerHTML = sanitizeHtml(markerSnippet); + snippet.innerHTML = sanitizeHtml(markerSnippet).toJS; } container.appendChild(snippet); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 55d663b4148..6dae93f7f96 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -5,8 +5,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 0.5.9 environment: - sdk: ^3.3.0 - flutter: ">=3.19.0" + sdk: ^3.4.0 + flutter: ">=3.22.0" flutter: plugin: @@ -22,11 +22,14 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - google_maps: ^8.0.0-dev.2 + google_maps: #^8.0.0-dev.3 + git: + url: git@github.com:ditman/a14n-dart-google-maps.git + ref: allow-web-1 google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 - web: ^0.5.1 + web: ">=0.5.1 <2.0.0" dev_dependencies: flutter_test: From 85f4037d4da4c667f32478194d3d9653e075917e Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 23 Jul 2024 20:26:55 -0700 Subject: [PATCH 22/35] Override git url from https instead of ssh. --- .../google_maps_flutter_web/example/pubspec.yaml | 2 +- .../google_maps_flutter/google_maps_flutter_web/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 6d9926b2db5..3dd25ddcac2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -19,7 +19,7 @@ dev_dependencies: sdk: flutter google_maps: #^8.0.0-dev.3 git: - url: git@github.com:ditman/a14n-dart-google-maps.git + url: https://github.com/ditman/a14n-dart-google-maps.git ref: allow-web-1 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart http: ^1.2.2 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 6dae93f7f96..480d86f923a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: sdk: flutter google_maps: #^8.0.0-dev.3 git: - url: git@github.com:ditman/a14n-dart-google-maps.git + url: https://github.com/ditman/a14n-dart-google-maps.git ref: allow-web-1 google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 From 0ef12c71b0920d58f2732842d12763fd6e7ad875 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 23 Jul 2024 20:45:29 -0700 Subject: [PATCH 23/35] Remove web:1.0.0 since the all_packages app still resolves to 0.5. --- .../google_maps_flutter/google_maps_flutter_web/CHANGELOG.md | 1 - .../google_maps_flutter_web/example/pubspec.yaml | 2 +- .../google_maps_flutter_web/lib/src/convert.dart | 2 +- .../google_maps_flutter/google_maps_flutter_web/pubspec.yaml | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 8e6e1498247..69f4b068810 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,7 +1,6 @@ # 0.5.9 * Updates `package:google_maps` dependency to latest (`^8.0.0`). -* Updates web code to allow package `web: ^1.0.0`. * Updates SDK version to Dart `^3.4.0`. Flutter `^3.22.0`. ## 0.5.8 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 3dd25ddcac2..87c26d49969 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: google_maps_flutter_platform_interface: ^2.7.0 google_maps_flutter_web: path: ../ - web: ^1.0.0 + web: ^0.5.1 dev_dependencies: build_runner: ^2.1.1 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 1a9819684b9..0032cf5a417 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -254,7 +254,7 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { // See: https://pub.dev/documentation/sanitize_html/latest/sanitize_html/sanitizeHtml.html // See: b/159137885, b/159598165 // ignore: unsafe_html - snippet.innerHTML = sanitizeHtml(markerSnippet).toJS; + snippet.innerHTML = sanitizeHtml(markerSnippet); } container.appendChild(snippet); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 480d86f923a..8a2769b34da 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -29,7 +29,7 @@ dependencies: google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 - web: ">=0.5.1 <2.0.0" + web: ^0.5.1 dev_dependencies: flutter_test: From 560bda454bb20edeef351a3dcf3f6cada7ba8956 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Wed, 24 Jul 2024 15:14:59 -0700 Subject: [PATCH 24/35] Support innerHTMLString through an extension, so the package works both with web 0.5.1 and 1.0.0. --- .../google_maps_flutter_web/example/pubspec.yaml | 7 ++----- .../google_maps_flutter_web/lib/src/convert.dart | 2 +- .../lib/src/dom_window_extension.dart | 7 +++++++ .../google_maps_flutter_web/pubspec.yaml | 7 ++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 87c26d49969..6a6c8c5a1bd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -11,16 +11,13 @@ dependencies: google_maps_flutter_platform_interface: ^2.7.0 google_maps_flutter_web: path: ../ - web: ^0.5.1 + web: ^1.0.0 dev_dependencies: build_runner: ^2.1.1 flutter_test: sdk: flutter - google_maps: #^8.0.0-dev.3 - git: - url: https://github.com/ditman/a14n-dart-google-maps.git - ref: allow-web-1 + google_maps: ^8.0.0-dev.4 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart http: ^1.2.2 integration_test: diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 0032cf5a417..dda30f23fa6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -254,7 +254,7 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { // See: https://pub.dev/documentation/sanitize_html/latest/sanitize_html/sanitizeHtml.html // See: b/159137885, b/159598165 // ignore: unsafe_html - snippet.innerHTML = sanitizeHtml(markerSnippet); + snippet.innerHTMLString = sanitizeHtml(markerSnippet); } container.appendChild(snippet); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart index 8c75229eb0c..87aa8304174 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart @@ -31,6 +31,13 @@ extension TrustedInnerHTML on web.HTMLElement { external set trustedInnerHTML(web.TrustedHTML trustedHTML); } +/// This extension allows supporting both web:0.5.1 and web:1.0.0. +/// To be removed once we stop using web:0.5.1. +extension InnerHTMLString on web.HTMLElement { + @JS('innerHTML') + external set innerHTMLString(String value); +} + /// Allows creating a TrustedHTML object from a string, with no arguments. extension CreateHTMLNoArgs on web.TrustedTypePolicy { /// Allows calling `createHTML` with only the `input` argument. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 8a2769b34da..2006e4cc9e3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -22,14 +22,11 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - google_maps: #^8.0.0-dev.3 - git: - url: https://github.com/ditman/a14n-dart-google-maps.git - ref: allow-web-1 + google_maps: ^8.0.0-dev.4 google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 - web: ^0.5.1 + web: ">=0.5.1 <2.0.0" dev_dependencies: flutter_test: From 924a000f33723de70af15237f2529740886bfcdf Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Wed, 24 Jul 2024 15:16:36 -0700 Subject: [PATCH 25/35] Update CHANGELOG.md --- .../google_maps_flutter/google_maps_flutter_web/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 69f4b068810..d1299dfcea6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.5.9 * Updates `package:google_maps` dependency to latest (`^8.0.0`). +* Supports `web: ">=0.5.1 <2.0.0"`. * Updates SDK version to Dart `^3.4.0`. Flutter `^3.22.0`. ## 0.5.8 From c5488cbd893857df1b70fa029af4f8da603e9a18 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 25 Jul 2024 18:18:41 -0700 Subject: [PATCH 26/35] Serve markerclusterer locally so wasm allows loading it. --- .../example/web/index.html | 2 +- .../markerclusterer@2.5.3/dist/index.min.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html b/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html index 4d058d79cc5..a2c72085a73 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html @@ -7,7 +7,7 @@ Browser Tests - + diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js b/packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js new file mode 100644 index 00000000000..23e23497b0e --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js @@ -0,0 +1,17 @@ +/** + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var markerClusterer=function(t){"use strict";function e(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);os.getVisible(t))).length}push(t){this.markers.push(t)}delete(){this.marker&&(s.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}}const o=(t,e,r,o)=>{const n=i(t.getBounds(),e,o);return r.filter((t=>n.contains(s.getPosition(t))))},i=(t,e,s)=>{const{northEast:r,southWest:o}=h(t,e),i=l({northEast:r,southWest:o},s);return c(i,e)},n=(t,e,s)=>{const r=i(t,e,s),o=r.getNorthEast(),n=r.getSouthWest();return[n.lng(),n.lat(),o.lng(),o.lat()]},a=(t,e)=>{const s=(e.lat-t.lat)*Math.PI/180,r=(e.lng-t.lng)*Math.PI/180,o=Math.sin(s/2),i=Math.sin(r/2),n=o*o+Math.cos(t.lat*Math.PI/180)*Math.cos(e.lat*Math.PI/180)*i*i;return 6371*(2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n)))},h=(t,e)=>({northEast:e.fromLatLngToDivPixel(t.getNorthEast()),southWest:e.fromLatLngToDivPixel(t.getSouthWest())}),l=(t,e)=>{let{northEast:s,southWest:r}=t;return s.x+=e,s.y-=e,r.x-=e,r.y+=e,{northEast:s,southWest:r}},c=(t,e)=>{let{northEast:s,southWest:r}=t;const o=e.fromDivPixelToLatLng(r),i=e.fromDivPixelToLatLng(s);return new google.maps.LatLngBounds(o,i)};class u{constructor(t){let{maxZoom:e=16}=t;this.maxZoom=e}noop(t){let{markers:e}=t;return m(e)}}class p extends u{constructor(t){var{viewportPadding:s=60}=t;super(e(t,["viewportPadding"])),this.viewportPadding=60,this.viewportPadding=s}calculate(t){let{markers:e,map:s,mapCanvasProjection:r}=t;return s.getZoom()>=this.maxZoom?{clusters:this.noop({markers:e}),changed:!1}:{clusters:this.cluster({markers:o(s,r,e,this.viewportPadding),map:s,mapCanvasProjection:r})}}}const m=t=>t.map((t=>new r({position:s.getPosition(t),markers:[t]})));function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var g=function t(e,s){if(e===s)return!0;if(e&&s&&"object"==typeof e&&"object"==typeof s){if(e.constructor!==s.constructor)return!1;var r,o,i;if(Array.isArray(e)){if((r=e.length)!=s.length)return!1;for(o=r;0!=o--;)if(!t(e[o],s[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===s.source&&e.flags===s.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===s.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===s.toString();if((r=(i=Object.keys(e)).length)!==Object.keys(s).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(s,i[o]))return!1;for(o=r;0!=o--;){var n=i[o];if(!t(e[n],s[n]))return!1}return!0}return e!=e&&s!=s},f=d(g);const k=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class w{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,s]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=s>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const o=k[15&s];if(!o)throw new Error("Unrecognized array type.");const[i]=new Uint16Array(t,2,1),[n]=new Uint32Array(t,4,1);return new w(n,i,o,t)}constructor(t,e=64,s=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const o=k.indexOf(this.ArrayType),i=2*t*this.ArrayType.BYTES_PER_ELEMENT,n=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-n%8)%8;if(o<0)throw new Error(`Unexpected typed array class: ${s}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+n+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+i+n+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+n+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+o]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=e,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return y(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,s,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:i,nodeSize:n}=this,a=[0,o.length-1,0],h=[];for(;a.length;){const l=a.pop()||0,c=a.pop()||0,u=a.pop()||0;if(c-u<=n){for(let n=u;n<=c;n++){const a=i[2*n],l=i[2*n+1];a>=t&&a<=s&&l>=e&&l<=r&&h.push(o[n])}continue}const p=u+c>>1,m=i[2*p],d=i[2*p+1];m>=t&&m<=s&&d>=e&&d<=r&&h.push(o[p]),(0===l?t<=m:e<=d)&&(a.push(u),a.push(p-1),a.push(1-l)),(0===l?s>=m:r>=d)&&(a.push(p+1),a.push(c),a.push(1-l))}return h}within(t,e,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:i}=this,n=[0,r.length-1,0],a=[],h=s*s;for(;n.length;){const l=n.pop()||0,c=n.pop()||0,u=n.pop()||0;if(c-u<=i){for(let s=u;s<=c;s++)C(o[2*s],o[2*s+1],t,e)<=h&&a.push(r[s]);continue}const p=u+c>>1,m=o[2*p],d=o[2*p+1];C(m,d,t,e)<=h&&a.push(r[p]),(0===l?t-s<=m:e-s<=d)&&(n.push(u),n.push(p-1),n.push(1-l)),(0===l?t+s>=m:e+s>=d)&&(n.push(p+1),n.push(c),n.push(1-l))}return a}}function y(t,e,s,r,o,i){if(o-r<=s)return;const n=r+o>>1;M(t,e,n,r,o,i),y(t,e,s,r,n-1,1-i),y(t,e,s,n+1,o,1-i)}function M(t,e,s,r,o,i){for(;o>r;){if(o-r>600){const n=o-r+1,a=s-r+1,h=Math.log(n),l=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*l*(n-l)/n)*(a-n/2<0?-1:1);M(t,e,s,Math.max(r,Math.floor(s-a*l/n+c)),Math.min(o,Math.floor(s+(n-a)*l/n+c)),i)}const n=e[2*s+i];let a=r,h=o;for(v(t,e,r,s),e[2*o+i]>n&&v(t,e,r,o);an;)h--}e[2*r+i]===n?v(t,e,r,h):(h++,v(t,e,h,o)),h<=s&&(r=h+1),s<=h&&(o=h-1)}}function v(t,e,s,r){x(t,s,r),x(e,2*s,2*r),x(e,2*s+1,2*r+1)}function x(t,e,s){const r=t[e];t[e]=t[s],t[s]=r}function C(t,e,s,r){const o=t-s,i=e-r;return o*o+i*i}const P={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},_=Math.fround||(E=new Float32Array(1),t=>(E[0]=+t,E[0]));var E;const A=3,b=5,L=6;class O{constructor(t){this.options=Object.assign(Object.create(P),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:s,maxZoom:r}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;const i=[];for(let e=0;e=s;t--){const s=+Date.now();n=this.trees[t]=this._createTree(this._cluster(n,t)),e&&console.log("z%d: %d clusters in %dms",t,n.numItems,+Date.now()-s)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let s=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let o=180===t[2]?180:((t[2]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)s=-180,o=180;else if(s>o){const t=this.getClusters([s,r,180,i],e),n=this.getClusters([-180,r,o,i],e);return t.concat(n)}const n=this.trees[this._limitZoom(e)],a=n.range(T(s),j(i),T(o),j(r)),h=n.data,l=[];for(const t of a){const e=this.stride*t;l.push(h[e+b]>1?Z(h,e,this.clusterProps):this.points[h[e+A]])}return l}getChildren(t){const e=this._getOriginId(t),s=this._getOriginZoom(t),r="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(r);const i=o.data;if(e*this.stride>=i.length)throw new Error(r);const n=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=i[e*this.stride],h=i[e*this.stride+1],l=o.within(a,h,n),c=[];for(const e of l){const s=e*this.stride;i[s+4]===t&&c.push(i[s+b]>1?Z(i,s,this.clusterProps):this.points[i[s+A]])}if(0===c.length)throw new Error(r);return c}getLeaves(t,e,s){e=e||10,s=s||0;const r=[];return this._appendLeaves(r,t,e,s,0),r}getTile(t,e,s){const r=this.trees[this._limitZoom(t)],o=Math.pow(2,t),{extent:i,radius:n}=this.options,a=n/i,h=(s-a)/o,l=(s+1+a)/o,c={features:[]};return this._addTileFeatures(r.range((e-a)/o,h,(e+1+a)/o,l),r.data,e,s,o,c),0===e&&this._addTileFeatures(r.range(1-a/o,h,1,l),r.data,o,s,o,c),e===o-1&&this._addTileFeatures(r.range(0,h,a/o,l),r.data,-1,s,o,c),c.features.length?c:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const s=this.getChildren(t);if(e++,1!==s.length)break;t=s[0].properties.cluster_id}return e}_appendLeaves(t,e,s,r,o){const i=this.getChildren(e);for(const e of i){const i=e.properties;if(i&&i.cluster?o+i.point_count<=r?o+=i.point_count:o=this._appendLeaves(t,i.cluster_id,s,r,o):o1;let h,l,c;if(a)h=I(e,t,this.clusterProps),l=e[t],c=e[t+1];else{const s=this.points[e[t+A]];h=s.properties;const[r,o]=s.geometry.coordinates;l=T(r),c=j(o)}const u={type:1,geometry:[[Math.round(this.options.extent*(l*o-s)),Math.round(this.options.extent*(c*o-r))]],tags:h};let p;p=a||this.options.generateId?e[t+A]:this.points[e[t+A]].id,void 0!==p&&(u.id=p),i.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:s,extent:r,reduce:o,minPoints:i}=this.options,n=s/(r*Math.pow(2,e)),a=t.data,h=[],l=this.stride;for(let s=0;se&&(m+=a[s+b])}if(m>p&&m>=i){let t,i=r*p,n=c*p,d=-1;const g=((s/l|0)<<5)+(e+1)+this.points.length;for(const r of u){const h=r*l;if(a[h+2]<=e)continue;a[h+2]=e;const c=a[h+b];i+=a[h]*c,n+=a[h+1]*c,a[h+4]=g,o&&(t||(t=this._map(a,s,!0),d=this.clusterProps.length,this.clusterProps.push(t)),o(t,this._map(a,h)))}a[s+4]=g,h.push(i/m,n/m,1/0,g,-1,m),o&&h.push(d)}else{for(let t=0;t1)for(const t of u){const s=t*l;if(!(a[s+2]<=e)){a[s+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,s){if(t[e+b]>1){const r=this.clusterProps[t[e+L]];return s?Object.assign({},r):r}const r=this.points[t[e+A]].properties,o=this.options.map(r);return s&&o===r?Object.assign({},o):o}}function Z(t,e,s){return{type:"Feature",id:t[e+A],properties:I(t,e,s),geometry:{type:"Point",coordinates:[(r=t[e],360*(r-.5)),S(t[e+1])]}};var r}function I(t,e,s){const r=t[e+b],o=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,i=t[e+L],n=-1===i?{}:Object.assign({},s[i]);return Object.assign(n,{cluster:!0,cluster_id:t[e+A],point_count:r,point_count_abbreviated:o})}function T(t){return t/360+.5}function j(t){const e=Math.sin(t*Math.PI/180),s=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return s<0?0:s>1?1:s}function S(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}class z extends u{constructor(t){var{maxZoom:s,radius:r=60}=t,o=e(t,["maxZoom","radius"]);super({maxZoom:s}),this.state={zoom:-1},this.superCluster=new O(Object.assign({maxZoom:this.maxZoom,radius:r},o))}calculate(t){let e=!1;const r={zoom:t.map.getZoom()};if(!f(t.markers,this.markers)){e=!0,this.markers=[...t.markers];const r=this.markers.map((t=>{const e=s.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}}));this.superCluster.load(r)}return e||(this.state.zoom<=this.maxZoom||r.zoom<=this.maxZoom)&&(e=!f(this.state,r)),this.state=r,e&&(this.clusters=this.cluster(t)),{clusters:this.clusters,changed:e}}cluster(t){let{map:e}=t;return this.superCluster.getClusters([-180,-90,180,90],Math.round(e.getZoom())).map((t=>this.transformCluster(t)))}transformCluster(t){let{geometry:{coordinates:[e,o]},properties:i}=t;if(i.cluster)return new r({markers:this.superCluster.getLeaves(i.cluster_id,1/0).map((t=>t.properties.marker)),position:{lat:o,lng:e}});const n=i.marker;return new r({markers:[n],position:s.getPosition(n)})}}class U{constructor(t,e){this.markers={sum:t.length};const s=e.map((t=>t.count)),r=s.reduce(((t,e)=>t+e),0);this.clusters={count:e.length,markers:{mean:r/e.length,sum:r,min:Math.min(...s),max:Math.max(...s)}}}}class B{render(t,e,r){let{count:o,position:i}=t;const n=`\n\n\n\n${o}\n`,a=`Cluster of ${o} markers`,h=Number(google.maps.Marker.MAX_ZINDEX)+o;if(s.isAdvancedMarkerAvailable(r)){const t=(new DOMParser).parseFromString(n,"image/svg+xml").documentElement;t.setAttribute("transform","translate(0 25)");const e={map:r,position:i,zIndex:h,title:a,content:t};return new google.maps.marker.AdvancedMarkerElement(e)}const l={position:i,zIndex:h,title:a,icon:{url:`data:image/svg+xml;base64,${btoa(n)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(l)}}class D{constructor(){!function(t,e){for(let s in e.prototype)t.prototype[s]=e.prototype[s]}(D,google.maps.OverlayView)}}var N;t.MarkerClustererEvents=void 0,(N=t.MarkerClustererEvents||(t.MarkerClustererEvents={})).CLUSTERING_BEGIN="clusteringbegin",N.CLUSTERING_END="clusteringend",N.CLUSTER_CLICK="click";const F=(t,e,s)=>{s.fitBounds(e.bounds)};return t.AbstractAlgorithm=u,t.AbstractViewportAlgorithm=p,t.Cluster=r,t.ClusterStats=U,t.DefaultRenderer=B,t.GridAlgorithm=class extends p{constructor(t){var{maxDistance:s=4e4,gridSize:r=40}=t;super(e(t,["maxDistance","gridSize"])),this.clusters=[],this.state={zoom:-1},this.maxDistance=s,this.gridSize=r}calculate(t){let{markers:e,map:s,mapCanvasProjection:r}=t;const i={zoom:s.getZoom()};let n=!1;return this.state.zoom>=this.maxZoom&&i.zoom>=this.maxZoom||(n=!f(this.state,i)),this.state=i,s.getZoom()>=this.maxZoom?{clusters:this.noop({markers:e}),changed:n}:{clusters:this.cluster({markers:o(s,r,e,this.viewportPadding),map:s,mapCanvasProjection:r})}}cluster(t){let{markers:e,map:s,mapCanvasProjection:r}=t;return this.clusters=[],e.forEach((t=>{this.addToClosestCluster(t,s,r)})),this.clusters}addToClosestCluster(t,e,o){let n=this.maxDistance,h=null;for(let e=0;e{this.addMarker(t,!0)})),e||this.render()}removeMarker(t,e){const r=this.markers.indexOf(t);return-1!==r&&(s.setMap(t,null),this.markers.splice(r,1),e||this.render(),!0)}removeMarkers(t,e){let s=!1;return t.forEach((t=>{s=this.removeMarker(t,!0)||s})),s&&!e&&this.render(),s}clearMarkers(t){this.markers.length=0,t||this.render()}render(){const e=this.getMap();if(e instanceof google.maps.Map&&e.getProjection()){google.maps.event.trigger(this,t.MarkerClustererEvents.CLUSTERING_BEGIN,this);const{clusters:r,changed:o}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(o||null==o){const t=new Set;for(const e of r)1==e.markers.length&&t.add(e.markers[0]);const e=[];for(const r of this.clusters)null!=r.marker&&(1==r.markers.length?t.has(r.marker)||s.setMap(r.marker,null):e.push(r.marker));this.clusters=r,this.renderClusters(),requestAnimationFrame((()=>e.forEach((t=>s.setMap(t,null)))))}google.maps.event.trigger(this,t.MarkerClustererEvents.CLUSTERING_END,this)}}onAdd(){this.idleListener=this.getMap().addListener("idle",this.render.bind(this)),this.render()}onRemove(){google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach((t=>s.setMap(t,null))),this.clusters.forEach((t=>t.delete())),this.clusters=[]}renderClusters(){const e=new U(this.markers,this.clusters),r=this.getMap();this.clusters.forEach((o=>{1===o.markers.length?o.marker=o.markers[0]:(o.marker=this.renderer.render(o,e,r),o.markers.forEach((t=>s.setMap(t,null))),this.onClusterClick&&o.marker.addListener("click",(e=>{google.maps.event.trigger(this,t.MarkerClustererEvents.CLUSTER_CLICK,o),this.onClusterClick(e,o,r)}))),s.setMap(o.marker,r)}))}},t.MarkerUtils=s,t.NoopAlgorithm=class extends u{constructor(t){super(e(t,[]))}calculate(t){let{markers:e,map:s,mapCanvasProjection:r}=t;return{clusters:this.cluster({markers:e,map:s,mapCanvasProjection:r}),changed:!1}}cluster(t){return this.noop(t)}},t.SuperClusterAlgorithm=z,t.SuperClusterViewportAlgorithm=class extends p{constructor(t){var{maxZoom:s,radius:r=60,viewportPadding:o=60}=t,i=e(t,["maxZoom","radius","viewportPadding"]);super({maxZoom:s,viewportPadding:o}),this.superCluster=new O(Object.assign({maxZoom:this.maxZoom,radius:r},i)),this.state={zoom:-1,view:[0,0,0,0]}}calculate(t){const e={zoom:Math.round(t.map.getZoom()),view:n(t.map.getBounds(),t.mapCanvasProjection,this.viewportPadding)};let r=!f(this.state,e);if(!f(t.markers,this.markers)){r=!0,this.markers=[...t.markers];const e=this.markers.map((t=>{const e=s.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}}));this.superCluster.load(e)}return r&&(this.clusters=this.cluster(t),this.state=e),{clusters:this.clusters,changed:r}}cluster(t){let{map:e,mapCanvasProjection:s}=t;const r={zoom:Math.round(e.getZoom()),view:n(e.getBounds(),s,this.viewportPadding)};return this.superCluster.getClusters(r.view,r.zoom).map((t=>this.transformCluster(t)))}transformCluster(t){let{geometry:{coordinates:[e,o]},properties:i}=t;if(i.cluster)return new r({markers:this.superCluster.getLeaves(i.cluster_id,1/0).map((t=>t.properties.marker)),position:{lat:o,lng:e}});const n=i.marker;return new r({markers:[n],position:s.getPosition(n)})}},t.defaultOnClusterClickHandler=F,t.distanceBetweenPoints=a,t.extendBoundsToPaddedViewport=i,t.extendPixelBounds=l,t.filterMarkersToPaddedViewport=o,t.getPaddedViewport=n,t.noop=m,t.pixelBoundsToLatLngBounds=c,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); +//# sourceMappingURL=index.min.js.map From a3ca0c436d7df9daa10421fb3ca130b7acbdf138 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 25 Jul 2024 18:19:15 -0700 Subject: [PATCH 27/35] Convert JSString.toDart properly. --- .../google_maps_flutter_web/lib/src/marker_clustering.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart index 89ad41bd481..8dbb4308ba6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'package:google_maps/google_maps.dart' as gmaps; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; @@ -127,7 +128,7 @@ class ClusterManagersController extends GeometryController { final List markerIds = markerClustererCluster.markers .map((gmaps.Marker marker) => - MarkerId(marker.get('markerId')! as String)) + MarkerId((marker.get('markerId')! as JSString).toDart)) .toList(); return Cluster( clusterManagerId, From dbb88478fdedd8a421d32e04f85cdde7088fe394 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 25 Jul 2024 18:49:34 -0700 Subject: [PATCH 28/35] Correctly read img.hidden in overlay_test.dart --- .../example/integration_test/overlay_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart index 26ba81bcd17..992d7559403 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart @@ -62,13 +62,15 @@ void main() { .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; expect(img.naturalWidth, 0); expect(img.naturalHeight, 0); - expect(img.hidden, true); + expect(img.hidden.isA(), isTrue); + expect(img.hidden, isNotNull); + expect((img.hidden! as JSBoolean).toDart, isTrue); await img.onLoad.first; await img.decode().toDart; - expect(img.hidden, false); + expect((img.hidden! as JSBoolean).toDart, false); expect(img.naturalWidth, 16); expect(img.naturalHeight, 16); }); From 7d65249dc96830314244dc169d8ad2a925f845e1 Mon Sep 17 00:00:00 2001 From: Rexios Date: Thu, 25 Jul 2024 22:10:05 -0400 Subject: [PATCH 29/35] Improve expect statement to match one below --- .../example/integration_test/overlay_test.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart index 992d7559403..8d192e18306 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart @@ -62,9 +62,7 @@ void main() { .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; expect(img.naturalWidth, 0); expect(img.naturalHeight, 0); - expect(img.hidden.isA(), isTrue); - expect(img.hidden, isNotNull); - expect((img.hidden! as JSBoolean).toDart, isTrue); + expect((img.hidden! as JSBoolean).toDart, true); await img.onLoad.first; From 0fb9b677d730e65b5de7dcee43293a0f67348563 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 25 Jul 2024 19:25:57 -0700 Subject: [PATCH 30/35] Read innerHTML correctly from markers_test.dart --- .../example/integration_test/markers_test.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart index 8de4a504149..f471c9c77cc 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:js_interop'; import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; @@ -464,9 +465,12 @@ void main() { expect(controller.markers.length, 1); final HTMLElement? content = controller .markers[const MarkerId('1')]?.infoWindow?.content as HTMLElement?; - expect(content?.innerHTML, contains('title for test')); + expect(content, isNotNull); + + final String innerHtml = (content!.innerHTML as JSString).toDart; + expect(innerHtml, contains('title for test')); expect( - content?.innerHTML, + innerHtml, contains( 'Go to Google >>>', )); From 87063e0882cd9b342a4486281f1fe66c8ac6fe60 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 25 Jul 2024 19:38:33 -0700 Subject: [PATCH 31/35] Cast properties from JS Shapes correctly in shapes_test.dart --- .../example/integration_test/shapes_test.dart | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart index 42b0e5b0fef..a6492a5b7bd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'dart:ui'; import 'package:flutter_test/flutter_test.dart'; @@ -108,10 +109,12 @@ void main() { final gmaps.Circle circle = controller.circles.values.first.circle!; - expect(circle.get('fillColor'), '#fabada'); - expect(circle.get('fillOpacity'), closeTo(0.5, _acceptableDelta)); - expect(circle.get('strokeColor'), '#c0ffee'); - expect(circle.get('strokeOpacity'), closeTo(1, _acceptableDelta)); + expect((circle.get('fillColor')! as JSString).toDart, '#fabada'); + expect((circle.get('fillOpacity')! as JSNumber).toDartDouble, + closeTo(0.5, _acceptableDelta)); + expect((circle.get('strokeColor')! as JSString).toDart, '#c0ffee'); + expect((circle.get('strokeOpacity')! as JSNumber).toDartDouble, + closeTo(1, _acceptableDelta)); }); }); @@ -197,10 +200,12 @@ void main() { final gmaps.Polygon polygon = controller.polygons.values.first.polygon!; - expect(polygon.get('fillColor'), '#fabada'); - expect(polygon.get('fillOpacity'), closeTo(0.5, _acceptableDelta)); - expect(polygon.get('strokeColor'), '#c0ffee'); - expect(polygon.get('strokeOpacity'), closeTo(1, _acceptableDelta)); + expect((polygon.get('fillColor')! as JSString).toDart, '#fabada'); + expect((polygon.get('fillOpacity')! as JSNumber).toDartDouble, + closeTo(0.5, _acceptableDelta)); + expect((polygon.get('strokeColor')! as JSString).toDart, '#c0ffee'); + expect((polygon.get('strokeOpacity')! as JSNumber).toDartDouble, + closeTo(1, _acceptableDelta)); }); testWidgets('Handle Polygons with holes', (WidgetTester tester) async { @@ -365,8 +370,9 @@ void main() { final gmaps.Polyline line = controller.lines.values.first.line!; - expect(line.get('strokeColor'), '#fabada'); - expect(line.get('strokeOpacity'), closeTo(0.5, _acceptableDelta)); + expect((line.get('strokeColor')! as JSString).toDart, '#fabada'); + expect((line.get('strokeOpacity')! as JSNumber).toDartDouble, + closeTo(0.5, _acceptableDelta)); }); }); } From 3e48fb230932bb44e54a8adcfb2e9d00f01e4baa Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Thu, 25 Jul 2024 19:46:36 -0700 Subject: [PATCH 32/35] Access deeply nested JS property in styler correctly in google_maps_plugin_test.dart --- .../example/integration_test/google_maps_plugin_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart index fdd9e6e5ef8..de813b2efae 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:js_interop'; import 'dart:js_interop_unsafe'; import 'package:flutter/widgets.dart'; @@ -192,7 +193,7 @@ void main() { expect(style.featureType, 'poi.park'); expect(style.elementType, 'labels.text.fill'); expect(style.stylers.length, 1); - expect(style.stylers[0]['color'], '#6b9a76'); + expect((style.stylers[0]['color']! as JSString).toDart, '#6b9a76'); }); testWidgets('throws MapStyleException for invalid styles', From 03d05dbda32e5b775db59e23442c8cbe58a0ab6b Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 26 Jul 2024 12:47:26 -0700 Subject: [PATCH 33/35] User marerclusterer from a CDN compliant with COEP/CORP so it works in Wasm. --- .../google_maps_flutter_web/README.md | 2 +- .../example/web/index.html | 2 +- .../markerclusterer@2.5.3/dist/index.min.js | 17 ----------------- 3 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js diff --git a/packages/google_maps_flutter/google_maps_flutter_web/README.md b/packages/google_maps_flutter/google_maps_flutter_web/README.md index c87e1082025..1873645d763 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/README.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/README.md @@ -59,7 +59,7 @@ If you need marker clustering support, modify the tag to load the [js-mar - + ``` diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html b/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html index a2c72085a73..fc6ddfcfa7b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/web/index.html @@ -7,7 +7,7 @@ Browser Tests - + diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js b/packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js deleted file mode 100644 index 23e23497b0e..00000000000 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/web/third_party/markerclusterer@2.5.3/dist/index.min.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright 2021 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -var markerClusterer=function(t){"use strict";function e(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);os.getVisible(t))).length}push(t){this.markers.push(t)}delete(){this.marker&&(s.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}}const o=(t,e,r,o)=>{const n=i(t.getBounds(),e,o);return r.filter((t=>n.contains(s.getPosition(t))))},i=(t,e,s)=>{const{northEast:r,southWest:o}=h(t,e),i=l({northEast:r,southWest:o},s);return c(i,e)},n=(t,e,s)=>{const r=i(t,e,s),o=r.getNorthEast(),n=r.getSouthWest();return[n.lng(),n.lat(),o.lng(),o.lat()]},a=(t,e)=>{const s=(e.lat-t.lat)*Math.PI/180,r=(e.lng-t.lng)*Math.PI/180,o=Math.sin(s/2),i=Math.sin(r/2),n=o*o+Math.cos(t.lat*Math.PI/180)*Math.cos(e.lat*Math.PI/180)*i*i;return 6371*(2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n)))},h=(t,e)=>({northEast:e.fromLatLngToDivPixel(t.getNorthEast()),southWest:e.fromLatLngToDivPixel(t.getSouthWest())}),l=(t,e)=>{let{northEast:s,southWest:r}=t;return s.x+=e,s.y-=e,r.x-=e,r.y+=e,{northEast:s,southWest:r}},c=(t,e)=>{let{northEast:s,southWest:r}=t;const o=e.fromDivPixelToLatLng(r),i=e.fromDivPixelToLatLng(s);return new google.maps.LatLngBounds(o,i)};class u{constructor(t){let{maxZoom:e=16}=t;this.maxZoom=e}noop(t){let{markers:e}=t;return m(e)}}class p extends u{constructor(t){var{viewportPadding:s=60}=t;super(e(t,["viewportPadding"])),this.viewportPadding=60,this.viewportPadding=s}calculate(t){let{markers:e,map:s,mapCanvasProjection:r}=t;return s.getZoom()>=this.maxZoom?{clusters:this.noop({markers:e}),changed:!1}:{clusters:this.cluster({markers:o(s,r,e,this.viewportPadding),map:s,mapCanvasProjection:r})}}}const m=t=>t.map((t=>new r({position:s.getPosition(t),markers:[t]})));function d(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var g=function t(e,s){if(e===s)return!0;if(e&&s&&"object"==typeof e&&"object"==typeof s){if(e.constructor!==s.constructor)return!1;var r,o,i;if(Array.isArray(e)){if((r=e.length)!=s.length)return!1;for(o=r;0!=o--;)if(!t(e[o],s[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===s.source&&e.flags===s.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===s.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===s.toString();if((r=(i=Object.keys(e)).length)!==Object.keys(s).length)return!1;for(o=r;0!=o--;)if(!Object.prototype.hasOwnProperty.call(s,i[o]))return!1;for(o=r;0!=o--;){var n=i[o];if(!t(e[n],s[n]))return!1}return!0}return e!=e&&s!=s},f=d(g);const k=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class w{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,s]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const r=s>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const o=k[15&s];if(!o)throw new Error("Unrecognized array type.");const[i]=new Uint16Array(t,2,1),[n]=new Uint32Array(t,4,1);return new w(n,i,o,t)}constructor(t,e=64,s=Float64Array,r){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const o=k.indexOf(this.ArrayType),i=2*t*this.ArrayType.BYTES_PER_ELEMENT,n=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-n%8)%8;if(o<0)throw new Error(`Unexpected typed array class: ${s}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+n+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+i+n+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+n+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+o]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=e,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return y(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,s,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:i,nodeSize:n}=this,a=[0,o.length-1,0],h=[];for(;a.length;){const l=a.pop()||0,c=a.pop()||0,u=a.pop()||0;if(c-u<=n){for(let n=u;n<=c;n++){const a=i[2*n],l=i[2*n+1];a>=t&&a<=s&&l>=e&&l<=r&&h.push(o[n])}continue}const p=u+c>>1,m=i[2*p],d=i[2*p+1];m>=t&&m<=s&&d>=e&&d<=r&&h.push(o[p]),(0===l?t<=m:e<=d)&&(a.push(u),a.push(p-1),a.push(1-l)),(0===l?s>=m:r>=d)&&(a.push(p+1),a.push(c),a.push(1-l))}return h}within(t,e,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:i}=this,n=[0,r.length-1,0],a=[],h=s*s;for(;n.length;){const l=n.pop()||0,c=n.pop()||0,u=n.pop()||0;if(c-u<=i){for(let s=u;s<=c;s++)C(o[2*s],o[2*s+1],t,e)<=h&&a.push(r[s]);continue}const p=u+c>>1,m=o[2*p],d=o[2*p+1];C(m,d,t,e)<=h&&a.push(r[p]),(0===l?t-s<=m:e-s<=d)&&(n.push(u),n.push(p-1),n.push(1-l)),(0===l?t+s>=m:e+s>=d)&&(n.push(p+1),n.push(c),n.push(1-l))}return a}}function y(t,e,s,r,o,i){if(o-r<=s)return;const n=r+o>>1;M(t,e,n,r,o,i),y(t,e,s,r,n-1,1-i),y(t,e,s,n+1,o,1-i)}function M(t,e,s,r,o,i){for(;o>r;){if(o-r>600){const n=o-r+1,a=s-r+1,h=Math.log(n),l=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*l*(n-l)/n)*(a-n/2<0?-1:1);M(t,e,s,Math.max(r,Math.floor(s-a*l/n+c)),Math.min(o,Math.floor(s+(n-a)*l/n+c)),i)}const n=e[2*s+i];let a=r,h=o;for(v(t,e,r,s),e[2*o+i]>n&&v(t,e,r,o);an;)h--}e[2*r+i]===n?v(t,e,r,h):(h++,v(t,e,h,o)),h<=s&&(r=h+1),s<=h&&(o=h-1)}}function v(t,e,s,r){x(t,s,r),x(e,2*s,2*r),x(e,2*s+1,2*r+1)}function x(t,e,s){const r=t[e];t[e]=t[s],t[s]=r}function C(t,e,s,r){const o=t-s,i=e-r;return o*o+i*i}const P={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},_=Math.fround||(E=new Float32Array(1),t=>(E[0]=+t,E[0]));var E;const A=3,b=5,L=6;class O{constructor(t){this.options=Object.assign(Object.create(P),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:s,maxZoom:r}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;const i=[];for(let e=0;e=s;t--){const s=+Date.now();n=this.trees[t]=this._createTree(this._cluster(n,t)),e&&console.log("z%d: %d clusters in %dms",t,n.numItems,+Date.now()-s)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let s=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let o=180===t[2]?180:((t[2]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)s=-180,o=180;else if(s>o){const t=this.getClusters([s,r,180,i],e),n=this.getClusters([-180,r,o,i],e);return t.concat(n)}const n=this.trees[this._limitZoom(e)],a=n.range(T(s),j(i),T(o),j(r)),h=n.data,l=[];for(const t of a){const e=this.stride*t;l.push(h[e+b]>1?Z(h,e,this.clusterProps):this.points[h[e+A]])}return l}getChildren(t){const e=this._getOriginId(t),s=this._getOriginZoom(t),r="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(r);const i=o.data;if(e*this.stride>=i.length)throw new Error(r);const n=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=i[e*this.stride],h=i[e*this.stride+1],l=o.within(a,h,n),c=[];for(const e of l){const s=e*this.stride;i[s+4]===t&&c.push(i[s+b]>1?Z(i,s,this.clusterProps):this.points[i[s+A]])}if(0===c.length)throw new Error(r);return c}getLeaves(t,e,s){e=e||10,s=s||0;const r=[];return this._appendLeaves(r,t,e,s,0),r}getTile(t,e,s){const r=this.trees[this._limitZoom(t)],o=Math.pow(2,t),{extent:i,radius:n}=this.options,a=n/i,h=(s-a)/o,l=(s+1+a)/o,c={features:[]};return this._addTileFeatures(r.range((e-a)/o,h,(e+1+a)/o,l),r.data,e,s,o,c),0===e&&this._addTileFeatures(r.range(1-a/o,h,1,l),r.data,o,s,o,c),e===o-1&&this._addTileFeatures(r.range(0,h,a/o,l),r.data,-1,s,o,c),c.features.length?c:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const s=this.getChildren(t);if(e++,1!==s.length)break;t=s[0].properties.cluster_id}return e}_appendLeaves(t,e,s,r,o){const i=this.getChildren(e);for(const e of i){const i=e.properties;if(i&&i.cluster?o+i.point_count<=r?o+=i.point_count:o=this._appendLeaves(t,i.cluster_id,s,r,o):o1;let h,l,c;if(a)h=I(e,t,this.clusterProps),l=e[t],c=e[t+1];else{const s=this.points[e[t+A]];h=s.properties;const[r,o]=s.geometry.coordinates;l=T(r),c=j(o)}const u={type:1,geometry:[[Math.round(this.options.extent*(l*o-s)),Math.round(this.options.extent*(c*o-r))]],tags:h};let p;p=a||this.options.generateId?e[t+A]:this.points[e[t+A]].id,void 0!==p&&(u.id=p),i.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:s,extent:r,reduce:o,minPoints:i}=this.options,n=s/(r*Math.pow(2,e)),a=t.data,h=[],l=this.stride;for(let s=0;se&&(m+=a[s+b])}if(m>p&&m>=i){let t,i=r*p,n=c*p,d=-1;const g=((s/l|0)<<5)+(e+1)+this.points.length;for(const r of u){const h=r*l;if(a[h+2]<=e)continue;a[h+2]=e;const c=a[h+b];i+=a[h]*c,n+=a[h+1]*c,a[h+4]=g,o&&(t||(t=this._map(a,s,!0),d=this.clusterProps.length,this.clusterProps.push(t)),o(t,this._map(a,h)))}a[s+4]=g,h.push(i/m,n/m,1/0,g,-1,m),o&&h.push(d)}else{for(let t=0;t1)for(const t of u){const s=t*l;if(!(a[s+2]<=e)){a[s+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,s){if(t[e+b]>1){const r=this.clusterProps[t[e+L]];return s?Object.assign({},r):r}const r=this.points[t[e+A]].properties,o=this.options.map(r);return s&&o===r?Object.assign({},o):o}}function Z(t,e,s){return{type:"Feature",id:t[e+A],properties:I(t,e,s),geometry:{type:"Point",coordinates:[(r=t[e],360*(r-.5)),S(t[e+1])]}};var r}function I(t,e,s){const r=t[e+b],o=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,i=t[e+L],n=-1===i?{}:Object.assign({},s[i]);return Object.assign(n,{cluster:!0,cluster_id:t[e+A],point_count:r,point_count_abbreviated:o})}function T(t){return t/360+.5}function j(t){const e=Math.sin(t*Math.PI/180),s=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return s<0?0:s>1?1:s}function S(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}class z extends u{constructor(t){var{maxZoom:s,radius:r=60}=t,o=e(t,["maxZoom","radius"]);super({maxZoom:s}),this.state={zoom:-1},this.superCluster=new O(Object.assign({maxZoom:this.maxZoom,radius:r},o))}calculate(t){let e=!1;const r={zoom:t.map.getZoom()};if(!f(t.markers,this.markers)){e=!0,this.markers=[...t.markers];const r=this.markers.map((t=>{const e=s.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}}));this.superCluster.load(r)}return e||(this.state.zoom<=this.maxZoom||r.zoom<=this.maxZoom)&&(e=!f(this.state,r)),this.state=r,e&&(this.clusters=this.cluster(t)),{clusters:this.clusters,changed:e}}cluster(t){let{map:e}=t;return this.superCluster.getClusters([-180,-90,180,90],Math.round(e.getZoom())).map((t=>this.transformCluster(t)))}transformCluster(t){let{geometry:{coordinates:[e,o]},properties:i}=t;if(i.cluster)return new r({markers:this.superCluster.getLeaves(i.cluster_id,1/0).map((t=>t.properties.marker)),position:{lat:o,lng:e}});const n=i.marker;return new r({markers:[n],position:s.getPosition(n)})}}class U{constructor(t,e){this.markers={sum:t.length};const s=e.map((t=>t.count)),r=s.reduce(((t,e)=>t+e),0);this.clusters={count:e.length,markers:{mean:r/e.length,sum:r,min:Math.min(...s),max:Math.max(...s)}}}}class B{render(t,e,r){let{count:o,position:i}=t;const n=`\n\n\n\n${o}\n`,a=`Cluster of ${o} markers`,h=Number(google.maps.Marker.MAX_ZINDEX)+o;if(s.isAdvancedMarkerAvailable(r)){const t=(new DOMParser).parseFromString(n,"image/svg+xml").documentElement;t.setAttribute("transform","translate(0 25)");const e={map:r,position:i,zIndex:h,title:a,content:t};return new google.maps.marker.AdvancedMarkerElement(e)}const l={position:i,zIndex:h,title:a,icon:{url:`data:image/svg+xml;base64,${btoa(n)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(l)}}class D{constructor(){!function(t,e){for(let s in e.prototype)t.prototype[s]=e.prototype[s]}(D,google.maps.OverlayView)}}var N;t.MarkerClustererEvents=void 0,(N=t.MarkerClustererEvents||(t.MarkerClustererEvents={})).CLUSTERING_BEGIN="clusteringbegin",N.CLUSTERING_END="clusteringend",N.CLUSTER_CLICK="click";const F=(t,e,s)=>{s.fitBounds(e.bounds)};return t.AbstractAlgorithm=u,t.AbstractViewportAlgorithm=p,t.Cluster=r,t.ClusterStats=U,t.DefaultRenderer=B,t.GridAlgorithm=class extends p{constructor(t){var{maxDistance:s=4e4,gridSize:r=40}=t;super(e(t,["maxDistance","gridSize"])),this.clusters=[],this.state={zoom:-1},this.maxDistance=s,this.gridSize=r}calculate(t){let{markers:e,map:s,mapCanvasProjection:r}=t;const i={zoom:s.getZoom()};let n=!1;return this.state.zoom>=this.maxZoom&&i.zoom>=this.maxZoom||(n=!f(this.state,i)),this.state=i,s.getZoom()>=this.maxZoom?{clusters:this.noop({markers:e}),changed:n}:{clusters:this.cluster({markers:o(s,r,e,this.viewportPadding),map:s,mapCanvasProjection:r})}}cluster(t){let{markers:e,map:s,mapCanvasProjection:r}=t;return this.clusters=[],e.forEach((t=>{this.addToClosestCluster(t,s,r)})),this.clusters}addToClosestCluster(t,e,o){let n=this.maxDistance,h=null;for(let e=0;e{this.addMarker(t,!0)})),e||this.render()}removeMarker(t,e){const r=this.markers.indexOf(t);return-1!==r&&(s.setMap(t,null),this.markers.splice(r,1),e||this.render(),!0)}removeMarkers(t,e){let s=!1;return t.forEach((t=>{s=this.removeMarker(t,!0)||s})),s&&!e&&this.render(),s}clearMarkers(t){this.markers.length=0,t||this.render()}render(){const e=this.getMap();if(e instanceof google.maps.Map&&e.getProjection()){google.maps.event.trigger(this,t.MarkerClustererEvents.CLUSTERING_BEGIN,this);const{clusters:r,changed:o}=this.algorithm.calculate({markers:this.markers,map:e,mapCanvasProjection:this.getProjection()});if(o||null==o){const t=new Set;for(const e of r)1==e.markers.length&&t.add(e.markers[0]);const e=[];for(const r of this.clusters)null!=r.marker&&(1==r.markers.length?t.has(r.marker)||s.setMap(r.marker,null):e.push(r.marker));this.clusters=r,this.renderClusters(),requestAnimationFrame((()=>e.forEach((t=>s.setMap(t,null)))))}google.maps.event.trigger(this,t.MarkerClustererEvents.CLUSTERING_END,this)}}onAdd(){this.idleListener=this.getMap().addListener("idle",this.render.bind(this)),this.render()}onRemove(){google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach((t=>s.setMap(t,null))),this.clusters.forEach((t=>t.delete())),this.clusters=[]}renderClusters(){const e=new U(this.markers,this.clusters),r=this.getMap();this.clusters.forEach((o=>{1===o.markers.length?o.marker=o.markers[0]:(o.marker=this.renderer.render(o,e,r),o.markers.forEach((t=>s.setMap(t,null))),this.onClusterClick&&o.marker.addListener("click",(e=>{google.maps.event.trigger(this,t.MarkerClustererEvents.CLUSTER_CLICK,o),this.onClusterClick(e,o,r)}))),s.setMap(o.marker,r)}))}},t.MarkerUtils=s,t.NoopAlgorithm=class extends u{constructor(t){super(e(t,[]))}calculate(t){let{markers:e,map:s,mapCanvasProjection:r}=t;return{clusters:this.cluster({markers:e,map:s,mapCanvasProjection:r}),changed:!1}}cluster(t){return this.noop(t)}},t.SuperClusterAlgorithm=z,t.SuperClusterViewportAlgorithm=class extends p{constructor(t){var{maxZoom:s,radius:r=60,viewportPadding:o=60}=t,i=e(t,["maxZoom","radius","viewportPadding"]);super({maxZoom:s,viewportPadding:o}),this.superCluster=new O(Object.assign({maxZoom:this.maxZoom,radius:r},i)),this.state={zoom:-1,view:[0,0,0,0]}}calculate(t){const e={zoom:Math.round(t.map.getZoom()),view:n(t.map.getBounds(),t.mapCanvasProjection,this.viewportPadding)};let r=!f(this.state,e);if(!f(t.markers,this.markers)){r=!0,this.markers=[...t.markers];const e=this.markers.map((t=>{const e=s.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}}));this.superCluster.load(e)}return r&&(this.clusters=this.cluster(t),this.state=e),{clusters:this.clusters,changed:r}}cluster(t){let{map:e,mapCanvasProjection:s}=t;const r={zoom:Math.round(e.getZoom()),view:n(e.getBounds(),s,this.viewportPadding)};return this.superCluster.getClusters(r.view,r.zoom).map((t=>this.transformCluster(t)))}transformCluster(t){let{geometry:{coordinates:[e,o]},properties:i}=t;if(i.cluster)return new r({markers:this.superCluster.getLeaves(i.cluster_id,1/0).map((t=>t.properties.marker)),position:{lat:o,lng:e}});const n=i.marker;return new r({markers:[n],position:s.getPosition(n)})}},t.defaultOnClusterClickHandler=F,t.distanceBetweenPoints=a,t.extendBoundsToPaddedViewport=i,t.extendPixelBounds=l,t.filterMarkersToPaddedViewport=o,t.getPaddedViewport=n,t.noop=m,t.pixelBoundsToLatLngBounds=c,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); -//# sourceMappingURL=index.min.js.map From b1c91bfe8ffa3b2292d9540f88d3812017f81ed9 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Tue, 30 Jul 2024 17:05:31 -0700 Subject: [PATCH 34/35] Bump to google_maps 8.0.0 --- .../google_maps_flutter/google_maps_flutter_web/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 2006e4cc9e3..5a20915dde3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: sdk: flutter flutter_web_plugins: sdk: flutter - google_maps: ^8.0.0-dev.4 + google_maps: ^8.0.0 google_maps_flutter_platform_interface: ^2.7.0 sanitize_html: ^2.0.0 stream_transform: ^2.0.0 From 613065e60990ac39025d179d01b2b055b281daca Mon Sep 17 00:00:00 2001 From: Rexios Date: Wed, 31 Jul 2024 08:41:53 -0400 Subject: [PATCH 35/35] Bump to google_maps 8.0.0 in example --- .../google_maps_flutter_web/example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 6a6c8c5a1bd..c789e7f9157 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -17,7 +17,7 @@ dev_dependencies: build_runner: ^2.1.1 flutter_test: sdk: flutter - google_maps: ^8.0.0-dev.4 + google_maps: ^8.0.0 google_maps_flutter: ^2.2.0 # Needed for projection_test.dart http: ^1.2.2 integration_test: