From 5a7a89a093683d00a6207302fecf5660dc22da38 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Wed, 4 Mar 2020 15:47:25 +0800 Subject: [PATCH 01/48] add google_maps_flutter_platform_interface --- .../CHANGELOG.md | 11 + .../LICENSE | 27 +++ .../README.md | 26 ++ ...oogle_maps_flutter_platform_interface.dart | 228 ++++++++++++++++++ .../method_channel_google_maps_flutter.dart | 197 +++++++++++++++ .../pubspec.yaml | 22 ++ ...thod_channel_google_maps_flutter_test.dart | 70 ++++++ 7 files changed, 581 insertions(+) create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/LICENSE create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/README.md create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml create mode 100644 packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md new file mode 100644 index 000000000000..5a2c14e8c728 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -0,0 +1,11 @@ +## 1.0.0 + +* Initial release. + +## 1.0.0+1 + +* Update README + +## 1.0.0+2 + +* Add PlatformInterface methods according to GoogleMapsFlutter \ No newline at end of file diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/LICENSE b/packages/google_maps_flutter/google_maps_flutter_platform_interface/LICENSE new file mode 100644 index 000000000000..8940a4be1b58 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/LICENSE @@ -0,0 +1,27 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/README.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/README.md new file mode 100644 index 000000000000..6489ba39cbd8 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/README.md @@ -0,0 +1,26 @@ +# google_maps_flutter_platform_interface + +A common platform interface for the [`google_maps_flutter`][1] plugin. + +This interface allows platform-specific implementations of the `google_maps_flutter` +plugin, as well as the plugin itself, to ensure they are supporting the +same interface. + +# Usage + +To implement a new platform-specific implementation of `google_maps_flutter`, extend +[`GoogleMapsFlutterPlatform`][2] with an implementation that performs the +platform-specific behavior, and when you register your plugin, set the default +`GoogleMapsFlutterPlatform` by calling +`GoogleMapsFlutterPlatform.instance = MyPlatformGoogleMapsFlutter()`. + +# Note on breaking changes + +Strongly prefer non-breaking changes (such as adding a method to the interface) +over breaking changes for this package. + +See https://flutter.dev/go/platform-interface-breaking-changes for a discussion +on why a less-clean interface is preferable to a breaking change. + +[1]: ../google_maps_flutter +[2]: lib/google_maps_flutter_platform_interface.dart diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart new file mode 100644 index 000000000000..98f7011f5e47 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart @@ -0,0 +1,228 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:ui'; + +import 'package:meta/meta.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'method_channel_google_maps_flutter.dart'; + +/// Exception when a map style is invalid or was unable to be set. +/// +/// See also: `setStyle` on [GoogleMapController] for why this exception +/// might be thrown. +class MapStyleException implements Exception { + /// Default constructor for [MapStyleException]. + const MapStyleException(this.cause); + + /// The reason `GoogleMapController.setStyle` would throw this exception. + final String cause; +} + + +/// Represents a point coordinate in the [GoogleMap]'s view. +/// +/// The screen location is specified in screen pixels (not display pixels) relative +/// to the top left of the map, not top left of the whole screen. (x, y) = (0, 0) +/// corresponds to top-left of the [GoogleMap] not the whole screen. +@immutable +class ScreenCoordinate { + /// Creates an immutable representation of a point coordinate in the [GoogleMap]'s view. + const ScreenCoordinate({ + @required this.x, + @required this.y, + }); + + /// Represents the number of pixels from the left of the [GoogleMap]. + final int x; + + /// Represents the number of pixels from the top of the [GoogleMap]. + final int y; + + /// [x] [y] coordinate in Json format + dynamic toJson() { + return { + "x": x, + "y": y, + }; + } + + @override + String toString() => '$runtimeType($x, $y)'; + + @override + bool operator ==(Object o) { + return o is ScreenCoordinate && o.x == x && o.y == y; + } + + @override + int get hashCode => hashValues(x, y); +} + +/// The interface that implementations of google_maps_flutter must implement. +/// +/// Platform implementations should extend this class rather than implement it as `google_maps_flutter` +/// does not consider newly added methods to be breaking changes. Extending this class +/// (using `extends`) ensures that the subclass will get the default implementation, while +/// platform implementations that `implements` this interface will be broken by newly added +/// [GoogleMapsFlutterPlatform] methods. +abstract class GoogleMapsFlutterPlatform extends PlatformInterface { + /// Constructs a GoogleMapsFlutterPlatform. + GoogleMapsFlutterPlatform() : super(token: _token); + + static final Object _token = Object(); + + static GoogleMapsFlutterPlatform _instance = MethodChannelGoogleMapsFlutter(0); + + /// The default instance of [GoogleMapsFlutterPlatform] to use. + /// + /// Defaults to [MethodChannelUrlLauncher]. + static GoogleMapsFlutterPlatform get instance => _instance; + + /// Platform-specific plugins should set this with their own platform-specific + /// class that extends [GoogleMapsFlutterPlatform] when they register themselves. + static set instance(GoogleMapsFlutterPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + /// Updates configuration options of the map user interface. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updateMapOptions(Map optionsUpdate) async { + throw UnimplementedError('updateMapOptions() has not been implemented.'); + } + + /// Updates marker configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updateMarkers(Map markerUpdates) async { + throw UnimplementedError('updateMarkers() has not been implemented.'); + } + + /// Updates polygon configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updatePolygons(Map polygonUpdates) async { + throw UnimplementedError('updatePolygons() has not been implemented.'); + } + + /// Updates polyline configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updatePolylines(Map polylineUpdates) async { + throw UnimplementedError('updatePolylines() has not been implemented.'); + } + + /// Updates circle configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updateCircles(Map circleUpdates) async { + throw UnimplementedError('updateCircles() has not been implemented.'); + } + + /// Starts an animated change of the map camera position. + /// + /// The returned [Future] completes after the change has been started on the + /// platform side. + Future animateCamera(Map cameraUpdate) async { + throw UnimplementedError('animateCamera() has not been implemented.'); + } + + /// Changes the map camera position. + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + Future moveCamera(Map cameraUpdate) async { + throw UnimplementedError('moveCamera() has not been implemented.'); + } + + /// Sets the styling of the base map. + /// + /// Set to `null` to clear any previous custom styling. + /// + /// If problems were detected with the [mapStyle], including un-parsable + /// styling JSON, unrecognized feature type, unrecognized element type, or + /// invalid styler keys: [MapStyleException] is thrown and the current + /// style is left unchanged. + /// + /// The style string can be generated using [map style tool](https://mapstyle.withgoogle.com/). + /// Also, refer [iOS](https://developers.google.com/maps/documentation/ios-sdk/style-reference) + /// and [Android](https://developers.google.com/maps/documentation/android-sdk/style-reference) + /// style reference for more information regarding the supported styles. + Future setMapStyle(String mapStyle) async { + throw UnimplementedError('setMapStyle() has not been implemented.'); + } + + /// Return [Map] defining the region that is visible in a map. + Future> getVisibleRegion() async { + throw UnimplementedError('getVisibleRegion() has not been implemented.'); + } + + /// Returns [List] corresponding to the [ScreenCoordinate] in the current map view. + /// + /// Returned [List] corresponds to a screen location. The screen location is specified in screen + /// pixels (not display pixels) relative to the top left of the map, not top left of the whole screen. + Future> getLatLng(ScreenCoordinate screenCoordinate) async { + throw UnimplementedError('getLatLng() has not been implemented.'); + } + + /// Programmatically show the Info Window for a [Marker]. + /// + /// The `markerId` must match one of the markers on the map. + /// An invalid `markerId` triggers an "Invalid markerId" error. + /// + /// * See also: + /// * [hideMarkerInfoWindow] to hide the Info Window. + /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. + Future showMarkerInfoWindow( String markerId ) async { + throw UnimplementedError('showMarkerInfoWindow() has not been implemented.'); + } + + /// Programmatically hide the Info Window for a [Marker]. + /// + /// The `markerId` must match one of the markers on the map. + /// An invalid `markerId` triggers an "Invalid markerId" error. + /// + /// * See also: + /// * [showMarkerInfoWindow] to show the Info Window. + /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. + Future hideMarkerInfoWindow(String markerId ) async { + throw UnimplementedError('hideMarkerInfoWindow() has not been implemented.'); + } + + /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. + /// + /// The `markerId` must match one of the markers on the map. + /// An invalid `markerId` triggers an "Invalid markerId" error. + /// + /// * See also: + /// * [showMarkerInfoWindow] to show the Info Window. + /// * [hideMarkerInfoWindow] to hide the Info Window. + Future isMarkerInfoWindowShown(String markerId ) async { + throw UnimplementedError('updateMapOptions() has not been implemented.'); + } + + /// Returns the current zoom level of the map + Future getZoomLevel() async { + throw UnimplementedError('getZoomLevel() has not been implemented.'); + } +} diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart new file mode 100644 index 000000000000..2d6d8829d5d7 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart @@ -0,0 +1,197 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/services.dart'; + +import 'google_maps_flutter_platform_interface.dart'; + +MethodChannel _channel; + +/// An implementation of [GoogleMapsFlutterPlatform] that uses method channels. +class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { + +///Initialize control of a [MethodChannelGoogleMapsFlutter] with [id]. + MethodChannelGoogleMapsFlutter(int id){ + _channel = MethodChannel('plugins.flutter.io/google_maps_$id'); + } + + /// Updates configuration options of the map user interface. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updateMapOptions(Map optionsUpdate) async { + assert(optionsUpdate != null); + await _channel.invokeMethod( + 'map#update', + { + 'options': optionsUpdate, + }, + ); + } + + /// Updates marker configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updateMarkers(Map markerUpdates) async { + assert(markerUpdates != null); + await _channel.invokeMethod( + 'markers#update', + markerUpdates, + ); + } + + /// Updates polygon configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updatePolygons(Map polygonUpdates) async { + assert(polygonUpdates != null); + await _channel.invokeMethod( + 'polygons#update', + polygonUpdates, + ); + } + + /// Updates polyline configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updatePolylines(Map polylineUpdates) async { + assert(polylineUpdates != null); + await _channel.invokeMethod( + 'polylines#update', + polylineUpdates, + ); + } + + /// Updates circle configuration. + /// + /// Change listeners are notified once the update has been made on the + /// platform side. + /// + /// The returned [Future] completes after listeners have been notified. + Future updateCircles(Map circleUpdates) async { + assert(circleUpdates != null); + await _channel.invokeMethod( + 'circles#update', + circleUpdates, + ); + } + + /// Starts an animated change of the map camera position. + /// + /// The returned [Future] completes after the change has been started on the + /// platform side. + Future animateCamera(dynamic cameraUpdate) async { + await _channel.invokeMethod('camera#animate', { + 'cameraUpdate': cameraUpdate, + }); + } + + /// Changes the map camera position. + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + Future moveCamera(dynamic cameraUpdate) async { + await _channel.invokeMethod('camera#move', { + 'cameraUpdate': cameraUpdate, + }); + } + + /// Sets the styling of the base map. + /// + /// Set to `null` to clear any previous custom styling. + /// + /// If problems were detected with the [mapStyle], including un-parsable + /// styling JSON, unrecognized feature type, unrecognized element type, or + /// invalid styler keys: [MapStyleException] is thrown and the current + /// style is left unchanged. + /// + /// The style string can be generated using [map style tool](https://mapstyle.withgoogle.com/). + /// Also, refer [iOS](https://developers.google.com/maps/documentation/ios-sdk/style-reference) + /// and [Android](https://developers.google.com/maps/documentation/android-sdk/style-reference) + /// style reference for more information regarding the supported styles. + Future setMapStyle(String mapStyle) async { + final List successAndError = + await _channel.invokeMethod>('map#setStyle', mapStyle); + final bool success = successAndError[0]; + if (!success) { + throw MapStyleException(successAndError[1]); + } + } + + /// Return [Map] defining the region that is visible in a map. + Future> getVisibleRegion() async { + return await _channel.invokeMapMethod('map#getVisibleRegion'); + } + + /// Returns [List] corresponding to the [ScreenCoordinate] in the current map view. + /// + /// Returned [List] corresponds to a screen location. The screen location is specified in screen + /// pixels (not display pixels) relative to the top left of the map, not top left of the whole screen. + Future> getLatLng(ScreenCoordinate screenCoordinate) async { + return await _channel.invokeMethod>( + 'map#getLatLng', screenCoordinate.toJson()); + } + + /// Programmatically show the Info Window for a [Marker]. + /// + /// The `markerId` must match one of the markers on the map. + /// An invalid `markerId` triggers an "Invalid markerId" error. + /// + /// * See also: + /// * [hideMarkerInfoWindow] to hide the Info Window. + /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. + Future showMarkerInfoWindow( String markerId ) async { + assert(markerId != null); + await _channel.invokeMethod( + 'markers#showInfoWindow', {'markerId': markerId}); + } + + /// Programmatically hide the Info Window for a [Marker]. + /// + /// The `markerId` must match one of the markers on the map. + /// An invalid `markerId` triggers an "Invalid markerId" error. + /// + /// * See also: + /// * [showMarkerInfoWindow] to show the Info Window. + /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. + Future hideMarkerInfoWindow(String markerId ) async { + assert(markerId != null); + await _channel.invokeMethod( + 'markers#hideInfoWindow', {'markerId': markerId}); + } + + /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. + /// + /// The `markerId` must match one of the markers on the map. + /// An invalid `markerId` triggers an "Invalid markerId" error. + /// + /// * See also: + /// * [showMarkerInfoWindow] to show the Info Window. + /// * [hideMarkerInfoWindow] to hide the Info Window. + Future isMarkerInfoWindowShown(String markerId ) async { + assert(markerId != null); + return await _channel.invokeMethod('markers#isInfoWindowShown', + {'markerId': markerId}); + } + + /// Returns the current zoom level of the map + Future getZoomLevel() async { + final double zoomLevel = + await _channel.invokeMethod('map#getZoomLevel'); + return zoomLevel; + } +} diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml new file mode 100644 index 000000000000..17fd5557d396 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -0,0 +1,22 @@ +name: google_maps_flutter_platform_interface +description: A common platform interface for the google_maps_flutter plugin. +homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface +# NOTE: We strongly prefer non-breaking changes, even at the expense of a +# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes +version: 1.0.0+2 + +dependencies: + flutter: + sdk: flutter + meta: ^1.0.5 + plugin_platform_interface: ^1.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + mockito: ^4.1.1 + pedantic: ^1.8.0 + +environment: + sdk: ">=2.0.0-dev.28.0 <3.0.0" + flutter: ">=1.9.1+hotfix.4 <2.0.0" diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart new file mode 100644 index 000000000000..d57bb38223cd --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart @@ -0,0 +1,70 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:mockito/mockito.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'package:google_maps_flutter_platform_interface/method_channel_google_maps_flutter.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('$GoogleMapsFlutterPlatform', () { + test('$MethodChannelGoogleMapsFlutter() is the default instance', () { + expect(GoogleMapsFlutterPlatform.instance, + isInstanceOf()); + }); + + test('Cannot be implemented with `implements`', () { + expect(() { + GoogleMapsFlutterPlatform.instance = ImplementsGoogleMapsFlutterPlatform(); + }, throwsA(isInstanceOf())); + }); + + test('Can be mocked with `implements`', () { + final GoogleMapsFlutterPlatformMock mock = GoogleMapsFlutterPlatformMock(); + GoogleMapsFlutterPlatform.instance = mock; + }); + + test('Can be extended', () { + GoogleMapsFlutterPlatform.instance = ExtendsGoogleMapsFlutterPlatform(); + }); + }); + + group('$MethodChannelGoogleMapsFlutter', () { + const MethodChannel channel = + MethodChannel('plugins.flutter.io/google_maps_flutter'); + final List log = []; + channel.setMockMethodCallHandler((MethodCall methodCall) async { + log.add(methodCall); + }); + + final MethodChannelGoogleMapsFlutter map = MethodChannelGoogleMapsFlutter(0); + + tearDown(() { + log.clear(); + }); + + test('foo', () async { +// await map.foo(); + expect( + log, + [ + ], + ); + }); + }); +} + +class GoogleMapsFlutterPlatformMock extends Mock + with MockPlatformInterfaceMixin + implements GoogleMapsFlutterPlatform {} + +class ImplementsGoogleMapsFlutterPlatform extends Mock + implements GoogleMapsFlutterPlatform {} + +class ExtendsGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform {} From 910c6ae9b7393ec11de4056d4a6c250906adb9a3 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Wed, 4 Mar 2020 16:04:19 +0800 Subject: [PATCH 02/48] removed unused_local_variable --- .../test/method_channel_google_maps_flutter_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart index d57bb38223cd..43f2bf2c1393 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart @@ -43,7 +43,7 @@ void main() { log.add(methodCall); }); - final MethodChannelGoogleMapsFlutter map = MethodChannelGoogleMapsFlutter(0); +// final MethodChannelGoogleMapsFlutter map = MethodChannelGoogleMapsFlutter(0); tearDown(() { log.clear(); From 5afbe027c1e1cbcb920cb381d0828d28b7fe9365 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Wed, 4 Mar 2020 16:25:00 +0800 Subject: [PATCH 03/48] format --- ...oogle_maps_flutter_platform_interface.dart | 16 ++++++++------ .../method_channel_google_maps_flutter.dart | 22 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart index 98f7011f5e47..59d3f64895f4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart @@ -22,7 +22,6 @@ class MapStyleException implements Exception { final String cause; } - /// Represents a point coordinate in the [GoogleMap]'s view. /// /// The screen location is specified in screen pixels (not display pixels) relative @@ -75,7 +74,8 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { static final Object _token = Object(); - static GoogleMapsFlutterPlatform _instance = MethodChannelGoogleMapsFlutter(0); + static GoogleMapsFlutterPlatform _instance = + MethodChannelGoogleMapsFlutter(0); /// The default instance of [GoogleMapsFlutterPlatform] to use. /// @@ -193,8 +193,9 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [hideMarkerInfoWindow] to hide the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future showMarkerInfoWindow( String markerId ) async { - throw UnimplementedError('showMarkerInfoWindow() has not been implemented.'); + Future showMarkerInfoWindow(String markerId) async { + throw UnimplementedError( + 'showMarkerInfoWindow() has not been implemented.'); } /// Programmatically hide the Info Window for a [Marker]. @@ -205,8 +206,9 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future hideMarkerInfoWindow(String markerId ) async { - throw UnimplementedError('hideMarkerInfoWindow() has not been implemented.'); + Future hideMarkerInfoWindow(String markerId) async { + throw UnimplementedError( + 'hideMarkerInfoWindow() has not been implemented.'); } /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. @@ -217,7 +219,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [hideMarkerInfoWindow] to hide the Info Window. - Future isMarkerInfoWindowShown(String markerId ) async { + Future isMarkerInfoWindowShown(String markerId) async { throw UnimplementedError('updateMapOptions() has not been implemented.'); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart index 2d6d8829d5d7..430a41d3ab02 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart @@ -12,9 +12,8 @@ MethodChannel _channel; /// An implementation of [GoogleMapsFlutterPlatform] that uses method channels. class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { - -///Initialize control of a [MethodChannelGoogleMapsFlutter] with [id]. - MethodChannelGoogleMapsFlutter(int id){ + ///Initialize control of a [MethodChannelGoogleMapsFlutter] with [id]. + MethodChannelGoogleMapsFlutter(int id) { _channel = MethodChannel('plugins.flutter.io/google_maps_$id'); } @@ -125,7 +124,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { /// style reference for more information regarding the supported styles. Future setMapStyle(String mapStyle) async { final List successAndError = - await _channel.invokeMethod>('map#setStyle', mapStyle); + await _channel.invokeMethod>('map#setStyle', mapStyle); final bool success = successAndError[0]; if (!success) { throw MapStyleException(successAndError[1]); @@ -134,7 +133,8 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { /// Return [Map] defining the region that is visible in a map. Future> getVisibleRegion() async { - return await _channel.invokeMapMethod('map#getVisibleRegion'); + return await _channel + .invokeMapMethod('map#getVisibleRegion'); } /// Returns [List] corresponding to the [ScreenCoordinate] in the current map view. @@ -154,7 +154,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { /// * See also: /// * [hideMarkerInfoWindow] to hide the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future showMarkerInfoWindow( String markerId ) async { + Future showMarkerInfoWindow(String markerId) async { assert(markerId != null); await _channel.invokeMethod( 'markers#showInfoWindow', {'markerId': markerId}); @@ -168,7 +168,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future hideMarkerInfoWindow(String markerId ) async { + Future hideMarkerInfoWindow(String markerId) async { assert(markerId != null); await _channel.invokeMethod( 'markers#hideInfoWindow', {'markerId': markerId}); @@ -182,16 +182,16 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [hideMarkerInfoWindow] to hide the Info Window. - Future isMarkerInfoWindowShown(String markerId ) async { + Future isMarkerInfoWindowShown(String markerId) async { assert(markerId != null); - return await _channel.invokeMethod('markers#isInfoWindowShown', - {'markerId': markerId}); + return await _channel.invokeMethod( + 'markers#isInfoWindowShown', {'markerId': markerId}); } /// Returns the current zoom level of the map Future getZoomLevel() async { final double zoomLevel = - await _channel.invokeMethod('map#getZoomLevel'); + await _channel.invokeMethod('map#getZoomLevel'); return zoomLevel; } } From 4c0ac1f2b7f91c6b81ae2e210e72e15b01afa8bd Mon Sep 17 00:00:00 2001 From: chung2012 Date: Wed, 4 Mar 2020 16:36:52 +0800 Subject: [PATCH 04/48] format --- .../test/method_channel_google_maps_flutter_test.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart index 43f2bf2c1393..7484fa2357cc 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart @@ -21,12 +21,14 @@ void main() { test('Cannot be implemented with `implements`', () { expect(() { - GoogleMapsFlutterPlatform.instance = ImplementsGoogleMapsFlutterPlatform(); + GoogleMapsFlutterPlatform.instance = + ImplementsGoogleMapsFlutterPlatform(); }, throwsA(isInstanceOf())); }); test('Can be mocked with `implements`', () { - final GoogleMapsFlutterPlatformMock mock = GoogleMapsFlutterPlatformMock(); + final GoogleMapsFlutterPlatformMock mock = + GoogleMapsFlutterPlatformMock(); GoogleMapsFlutterPlatform.instance = mock; }); @@ -37,7 +39,7 @@ void main() { group('$MethodChannelGoogleMapsFlutter', () { const MethodChannel channel = - MethodChannel('plugins.flutter.io/google_maps_flutter'); + MethodChannel('plugins.flutter.io/google_maps_flutter'); final List log = []; channel.setMockMethodCallHandler((MethodCall methodCall) async { log.add(methodCall); From 5276fbc2b8b689aaecec40938fc3dde8870fdb85 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Wed, 4 Mar 2020 16:42:20 +0800 Subject: [PATCH 05/48] format# --- .../test/method_channel_google_maps_flutter_test.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart index 7484fa2357cc..ea08bad7b31a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel_google_maps_flutter_test.dart @@ -39,7 +39,7 @@ void main() { group('$MethodChannelGoogleMapsFlutter', () { const MethodChannel channel = - MethodChannel('plugins.flutter.io/google_maps_flutter'); + MethodChannel('plugins.flutter.io/google_maps_flutter'); final List log = []; channel.setMockMethodCallHandler((MethodCall methodCall) async { log.add(methodCall); @@ -55,8 +55,7 @@ void main() { // await map.foo(); expect( log, - [ - ], + [], ); }); }); From 9c35d4cb3cc03bae87ef1b715d5c95b538ff5451 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Wed, 4 Mar 2020 19:12:32 +0800 Subject: [PATCH 06/48] update CHANGELOG --- .../CHANGELOG.md | 11 +++++++---- .../pubspec.yaml | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md index 5a2c14e8c728..b08f0559b70c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -1,11 +1,14 @@ -## 1.0.0 +## 1.0.0+3 +* Clean up format -* Initial release. +## 1.0.0+2 + +* Add PlatformInterface methods according to GoogleMapsFlutter ## 1.0.0+1 * Update README -## 1.0.0+2 +## 1.0.0 -* Add PlatformInterface methods according to GoogleMapsFlutter \ No newline at end of file +* Initial release. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 17fd5557d396..12cc9e957a6b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the google_maps_flutter plugin. homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 1.0.0+2 +version: 1.0.0+3 dependencies: flutter: From 0d99e157531d9b02916fdbf19980fd1979ccd1e2 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Thu, 5 Mar 2020 15:16:19 +0800 Subject: [PATCH 07/48] Move MethodChannel code to MethodChannelGoogleMapsFlutter --- .../google_maps_flutter/CHANGELOG.md | 4 + .../lib/google_maps_flutter.dart | 2 + .../lib/src/controller.dart | 79 +++++---------- .../google_maps_flutter/pubspec.yaml | 6 +- .../CHANGELOG.md | 3 + ...oogle_maps_flutter_platform_interface.dart | 98 ++++++++----------- .../method_channel_google_maps_flutter.dart | 30 +++++- .../pubspec.yaml | 2 +- 8 files changed, 110 insertions(+), 114 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 1027affdf24a..fa0ac1051482 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.0 + +* Move MethodChannel code to MethodChannelGoogleMapsFlutter (Flutter Platform Interface) + ## 0.5.25+3 * Rename 'Page' in the example app to avoid type conflict with the Flutter Framework. diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart index 5f3889f7b2f1..e1481e4896fc 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart @@ -13,6 +13,8 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; + part 'src/bitmap.dart'; part 'src/callbacks.dart'; part 'src/camera.dart'; diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart index 750bb69393e7..3c48a3199913 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart @@ -4,14 +4,16 @@ part of google_maps_flutter; +final GoogleMapsFlutterPlatform _googleMapsFlutterPlatform = + GoogleMapsFlutterPlatform.instance; + /// Controller for a single GoogleMap instance running on the host platform. class GoogleMapController { GoogleMapController._( - this.channel, CameraPosition initialCameraPosition, this._googleMapState, - ) : assert(channel != null) { - channel.setMethodCallHandler(_handleMethodCall); + ) : assert(_googleMapsFlutterPlatform != null) { + _googleMapsFlutterPlatform.setMethodCallHandler(_handleMethodCall); } /// Initialize control of a [GoogleMap] with [id]. @@ -24,11 +26,8 @@ class GoogleMapController { _GoogleMapState googleMapState, ) async { assert(id != null); - final MethodChannel channel = - MethodChannel('plugins.flutter.io/google_maps_$id'); - await channel.invokeMethod('map#waitForMap'); + _googleMapsFlutterPlatform.init(id); return GoogleMapController._( - channel, initialCameraPosition, googleMapState, ); @@ -38,7 +37,7 @@ class GoogleMapController { /// /// Accessible only for testing. @visibleForTesting - final MethodChannel channel; + MethodChannel channel; final _GoogleMapState _googleMapState; @@ -100,12 +99,7 @@ class GoogleMapController { /// The returned [Future] completes after listeners have been notified. Future _updateMapOptions(Map optionsUpdate) async { assert(optionsUpdate != null); - await channel.invokeMethod( - 'map#update', - { - 'options': optionsUpdate, - }, - ); + await _googleMapsFlutterPlatform.updateMapOptions(optionsUpdate); } /// Updates marker configuration. @@ -116,10 +110,7 @@ class GoogleMapController { /// The returned [Future] completes after listeners have been notified. Future _updateMarkers(_MarkerUpdates markerUpdates) async { assert(markerUpdates != null); - await channel.invokeMethod( - 'markers#update', - markerUpdates._toMap(), - ); + await _googleMapsFlutterPlatform.updateMarkers(markerUpdates._toMap()); } /// Updates polygon configuration. @@ -130,10 +121,7 @@ class GoogleMapController { /// The returned [Future] completes after listeners have been notified. Future _updatePolygons(_PolygonUpdates polygonUpdates) async { assert(polygonUpdates != null); - await channel.invokeMethod( - 'polygons#update', - polygonUpdates._toMap(), - ); + await _googleMapsFlutterPlatform.updatePolygons(polygonUpdates._toMap()); } /// Updates polyline configuration. @@ -144,10 +132,7 @@ class GoogleMapController { /// The returned [Future] completes after listeners have been notified. Future _updatePolylines(_PolylineUpdates polylineUpdates) async { assert(polylineUpdates != null); - await channel.invokeMethod( - 'polylines#update', - polylineUpdates._toMap(), - ); + await _googleMapsFlutterPlatform.updatePolylines(polylineUpdates._toMap()); } /// Updates circle configuration. @@ -158,10 +143,7 @@ class GoogleMapController { /// The returned [Future] completes after listeners have been notified. Future _updateCircles(_CircleUpdates circleUpdates) async { assert(circleUpdates != null); - await channel.invokeMethod( - 'circles#update', - circleUpdates._toMap(), - ); + await _googleMapsFlutterPlatform.updateCircles(circleUpdates._toMap()); } /// Starts an animated change of the map camera position. @@ -169,9 +151,7 @@ class GoogleMapController { /// The returned [Future] completes after the change has been started on the /// platform side. Future animateCamera(CameraUpdate cameraUpdate) async { - await channel.invokeMethod('camera#animate', { - 'cameraUpdate': cameraUpdate._toJson(), - }); + await _googleMapsFlutterPlatform.animateCamera(cameraUpdate._toJson()); } /// Changes the map camera position. @@ -179,9 +159,7 @@ class GoogleMapController { /// The returned [Future] completes after the change has been made on the /// platform side. Future moveCamera(CameraUpdate cameraUpdate) async { - await channel.invokeMethod('camera#move', { - 'cameraUpdate': cameraUpdate._toJson(), - }); + await _googleMapsFlutterPlatform.moveCamera(cameraUpdate._toJson()); } /// Sets the styling of the base map. @@ -198,18 +176,13 @@ class GoogleMapController { /// and [Android](https://developers.google.com/maps/documentation/android-sdk/style-reference) /// style reference for more information regarding the supported styles. Future setMapStyle(String mapStyle) async { - final List successAndError = - await channel.invokeMethod>('map#setStyle', mapStyle); - final bool success = successAndError[0]; - if (!success) { - throw MapStyleException(successAndError[1]); - } + await _googleMapsFlutterPlatform.setMapStyle(mapStyle); } /// Return [LatLngBounds] defining the region that is visible in a map. Future getVisibleRegion() async { final Map latLngBounds = - await channel.invokeMapMethod('map#getVisibleRegion'); + await _googleMapsFlutterPlatform.getVisibleRegion(); final LatLng southwest = LatLng._fromJson(latLngBounds['southwest']); final LatLng northeast = LatLng._fromJson(latLngBounds['northeast']); @@ -222,8 +195,8 @@ class GoogleMapController { /// Screen location is in screen pixels (not display pixels) with respect to the top left corner /// of the map, not necessarily of the whole screen. Future getScreenCoordinate(LatLng latLng) async { - final Map point = await channel.invokeMapMethod( - 'map#getScreenCoordinate', latLng._toJson()); + final Map point = + await _googleMapsFlutterPlatform.getScreenCoordinate(latLng._toJson()); return ScreenCoordinate(x: point['x'], y: point['y']); } @@ -232,8 +205,8 @@ class GoogleMapController { /// Returned [LatLng] corresponds to a screen location. The screen location is specified in screen /// pixels (not display pixels) relative to the top left of the map, not top left of the whole screen. Future getLatLng(ScreenCoordinate screenCoordinate) async { - final List latLng = await channel.invokeMethod>( - 'map#getLatLng', screenCoordinate._toJson()); + final List latLng = + await _googleMapsFlutterPlatform.getLatLng(screenCoordinate._toJson()); return LatLng(latLng[0], latLng[1]); } @@ -247,8 +220,7 @@ class GoogleMapController { /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. Future showMarkerInfoWindow(MarkerId markerId) async { assert(markerId != null); - await channel.invokeMethod( - 'markers#showInfoWindow', {'markerId': markerId.value}); + await _googleMapsFlutterPlatform.showMarkerInfoWindow(markerId.value); } /// Programmatically hide the Info Window for a [Marker]. @@ -261,8 +233,7 @@ class GoogleMapController { /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. Future hideMarkerInfoWindow(MarkerId markerId) async { assert(markerId != null); - await channel.invokeMethod( - 'markers#hideInfoWindow', {'markerId': markerId.value}); + await _googleMapsFlutterPlatform.hideMarkerInfoWindow(markerId.value); } /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. @@ -275,14 +246,12 @@ class GoogleMapController { /// * [hideMarkerInfoWindow] to hide the Info Window. Future isMarkerInfoWindowShown(MarkerId markerId) async { assert(markerId != null); - return await channel.invokeMethod('markers#isInfoWindowShown', - {'markerId': markerId.value}); + return _googleMapsFlutterPlatform.isMarkerInfoWindowShown(markerId.value); } /// Returns the current zoom level of the map Future getZoomLevel() async { - final double zoomLevel = - await channel.invokeMethod('map#getZoomLevel'); + final double zoomLevel = await _googleMapsFlutterPlatform.getZoomLevel(); return zoomLevel; } diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 0f88a9a0ad18..5ac431b4aec3 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -1,12 +1,14 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter -version: 0.5.25+3 +version: 0.6.0 dependencies: flutter: sdk: flutter flutter_plugin_android_lifecycle: ^1.0.0 + google_maps_flutter_platform_interface: + google_maps_flutter_web: dev_dependencies: flutter_test: @@ -27,6 +29,8 @@ flutter: pluginClass: GoogleMapsPlugin ios: pluginClass: FLTGoogleMapsPlugin + web: + default_package: google_maps_flutter_web environment: sdk: ">=2.0.0-dev.47.0 <3.0.0" diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md index b08f0559b70c..5442f6828779 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.0.0+4 +* Add init method and Move MethodChannel code to MethodChannelGoogleMapsFlutter + ## 1.0.0+3 * Clean up format diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart index 59d3f64895f4..9888c4b6f63b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'dart:ui'; +import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -22,45 +23,6 @@ class MapStyleException implements Exception { final String cause; } -/// Represents a point coordinate in the [GoogleMap]'s view. -/// -/// The screen location is specified in screen pixels (not display pixels) relative -/// to the top left of the map, not top left of the whole screen. (x, y) = (0, 0) -/// corresponds to top-left of the [GoogleMap] not the whole screen. -@immutable -class ScreenCoordinate { - /// Creates an immutable representation of a point coordinate in the [GoogleMap]'s view. - const ScreenCoordinate({ - @required this.x, - @required this.y, - }); - - /// Represents the number of pixels from the left of the [GoogleMap]. - final int x; - - /// Represents the number of pixels from the top of the [GoogleMap]. - final int y; - - /// [x] [y] coordinate in Json format - dynamic toJson() { - return { - "x": x, - "y": y, - }; - } - - @override - String toString() => '$runtimeType($x, $y)'; - - @override - bool operator ==(Object o) { - return o is ScreenCoordinate && o.x == x && o.y == y; - } - - @override - int get hashCode => hashValues(x, y); -} - /// The interface that implementations of google_maps_flutter must implement. /// /// Platform implementations should extend this class rather than implement it as `google_maps_flutter` @@ -89,13 +51,27 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { _instance = instance; } + /// /// Initializes the platform interface with [id]. + /// + /// This method is called when the plugin is first initialized. + Future init(int id) { + throw UnimplementedError('init() has not been implemented.'); + } + + MethodChannel get channel {} + + void setMethodCallHandler(dynamic call) { + throw UnimplementedError( + 'setMethodCallHandler() has not been implemented.'); + } + /// Updates configuration options of the map user interface. /// /// Change listeners are notified once the update has been made on the /// platform side. /// /// The returned [Future] completes after listeners have been notified. - Future updateMapOptions(Map optionsUpdate) async { + Future updateMapOptions(Map optionsUpdate) { throw UnimplementedError('updateMapOptions() has not been implemented.'); } @@ -105,7 +81,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// platform side. /// /// The returned [Future] completes after listeners have been notified. - Future updateMarkers(Map markerUpdates) async { + Future updateMarkers(Map markerUpdates) { throw UnimplementedError('updateMarkers() has not been implemented.'); } @@ -115,7 +91,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// platform side. /// /// The returned [Future] completes after listeners have been notified. - Future updatePolygons(Map polygonUpdates) async { + Future updatePolygons(Map polygonUpdates) { throw UnimplementedError('updatePolygons() has not been implemented.'); } @@ -125,7 +101,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// platform side. /// /// The returned [Future] completes after listeners have been notified. - Future updatePolylines(Map polylineUpdates) async { + Future updatePolylines(Map polylineUpdates) { throw UnimplementedError('updatePolylines() has not been implemented.'); } @@ -135,7 +111,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// platform side. /// /// The returned [Future] completes after listeners have been notified. - Future updateCircles(Map circleUpdates) async { + Future updateCircles(Map circleUpdates) { throw UnimplementedError('updateCircles() has not been implemented.'); } @@ -143,7 +119,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// /// The returned [Future] completes after the change has been started on the /// platform side. - Future animateCamera(Map cameraUpdate) async { + Future animateCamera(dynamic cameraUpdate) { throw UnimplementedError('animateCamera() has not been implemented.'); } @@ -151,7 +127,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// /// The returned [Future] completes after the change has been made on the /// platform side. - Future moveCamera(Map cameraUpdate) async { + Future moveCamera(dynamic cameraUpdate) { throw UnimplementedError('moveCamera() has not been implemented.'); } @@ -168,23 +144,33 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// Also, refer [iOS](https://developers.google.com/maps/documentation/ios-sdk/style-reference) /// and [Android](https://developers.google.com/maps/documentation/android-sdk/style-reference) /// style reference for more information regarding the supported styles. - Future setMapStyle(String mapStyle) async { + Future setMapStyle(String mapStyle) { throw UnimplementedError('setMapStyle() has not been implemented.'); } /// Return [Map] defining the region that is visible in a map. - Future> getVisibleRegion() async { + Future> getVisibleRegion() { throw UnimplementedError('getVisibleRegion() has not been implemented.'); } - /// Returns [List] corresponding to the [ScreenCoordinate] in the current map view. + /// Return point [Map] of the [latLngInJson] in the current map view. /// - /// Returned [List] corresponds to a screen location. The screen location is specified in screen - /// pixels (not display pixels) relative to the top left of the map, not top left of the whole screen. - Future> getLatLng(ScreenCoordinate screenCoordinate) async { + /// A projection is used to translate between on screen location and geographic coordinates. + /// Screen location is in screen pixels (not display pixels) with respect to the top left corner + /// of the map, not necessarily of the whole screen. + Future> getLatLng(dynamic latLng) { throw UnimplementedError('getLatLng() has not been implemented.'); } + /// Return point [Map] of the [screenCoordinateInJson] in the current map view. + /// + /// A projection is used to translate between on screen location and geographic coordinates. + /// Screen location is in screen pixels (not display pixels) with respect to the top left corner + /// of the map, not necessarily of the whole screen. + Future> getScreenCoordinate(dynamic screenCoordinateInJson) { + throw UnimplementedError('getScreenCoordinate() has not been implemented.'); + } + /// Programmatically show the Info Window for a [Marker]. /// /// The `markerId` must match one of the markers on the map. @@ -193,7 +179,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [hideMarkerInfoWindow] to hide the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future showMarkerInfoWindow(String markerId) async { + Future showMarkerInfoWindow(String markerId) { throw UnimplementedError( 'showMarkerInfoWindow() has not been implemented.'); } @@ -206,7 +192,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future hideMarkerInfoWindow(String markerId) async { + Future hideMarkerInfoWindow(String markerId) { throw UnimplementedError( 'hideMarkerInfoWindow() has not been implemented.'); } @@ -219,12 +205,12 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [hideMarkerInfoWindow] to hide the Info Window. - Future isMarkerInfoWindowShown(String markerId) async { + Future isMarkerInfoWindowShown(String markerId) { throw UnimplementedError('updateMapOptions() has not been implemented.'); } /// Returns the current zoom level of the map - Future getZoomLevel() async { + Future getZoomLevel() { throw UnimplementedError('getZoomLevel() has not been implemented.'); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart index 430a41d3ab02..e60e35038f57 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart @@ -17,6 +17,22 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { _channel = MethodChannel('plugins.flutter.io/google_maps_$id'); } + /// /// Initializes the platform interface with [id]. + /// + /// This method is called when the plugin is first initialized. + Future init(int id) async { + _channel = MethodChannel('plugins.flutter.io/google_maps_$id'); + await _channel.invokeMethod('map#waitForMap'); + } + + MethodChannel get channel { + return _channel; + } + + void setMethodCallHandler(dynamic call) { + _channel.setMethodCallHandler(call); + } + /// Updates configuration options of the map user interface. /// /// Change listeners are notified once the update has been made on the @@ -137,11 +153,23 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { .invokeMapMethod('map#getVisibleRegion'); } + /// Return point [Map] of the [screenCoordinateInJson] in the current map view. + /// + /// A projection is used to translate between on screen location and geographic coordinates. + /// Screen location is in screen pixels (not display pixels) with respect to the top left corner + /// of the map, not necessarily of the whole screen. + Future> getScreenCoordinate( + dynamic screenCoordinateInJson) async { + final Map point = await _channel.invokeMapMethod( + 'map#getScreenCoordinate', screenCoordinateInJson); + return point; + } + /// Returns [List] corresponding to the [ScreenCoordinate] in the current map view. /// /// Returned [List] corresponds to a screen location. The screen location is specified in screen /// pixels (not display pixels) relative to the top left of the map, not top left of the whole screen. - Future> getLatLng(ScreenCoordinate screenCoordinate) async { + Future> getLatLng(dynamic screenCoordinate) async { return await _channel.invokeMethod>( 'map#getLatLng', screenCoordinate.toJson()); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 12cc9e957a6b..ed39ce659a4d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the google_maps_flutter plugin. homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 1.0.0+3 +version: 1.0.0+4 dependencies: flutter: From 152bd4a1f8a99ca7f80a8f29c820fb36e5d03c3f Mon Sep 17 00:00:00 2001 From: chung2012 Date: Thu, 5 Mar 2020 16:02:56 +0800 Subject: [PATCH 08/48] Update dependencies --- packages/google_maps_flutter/google_maps_flutter/pubspec.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 5ac431b4aec3..ab7a3390369c 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -8,7 +8,9 @@ dependencies: sdk: flutter flutter_plugin_android_lifecycle: ^1.0.0 google_maps_flutter_platform_interface: - google_maps_flutter_web: + path: ../google_maps_flutter_platform_interface +# google_maps_flutter_web: +# path: ../google_maps_flutter_web dev_dependencies: flutter_test: From 6c2a92c4e0ece46858e22e33cb4f6c68fc47f44f Mon Sep 17 00:00:00 2001 From: chung2012 Date: Mon, 9 Mar 2020 09:01:39 +0800 Subject: [PATCH 09/48] add buildView method --- .../google_maps_flutter/example/.gitignore | 40 +++++++++++++++++ .../example/android/.gitignore | 7 +++ .../flutter/plugins/example/MainActivity.kt | 12 +++++ .../example/ios/.gitignore | 32 +++++++++++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 ++++ .../example/ios/Runner/AppDelegate.swift | 13 ++++++ .../ios/Runner/Runner-Bridging-Header.h | 1 + .../google_maps_flutter/example/pubspec.yaml | 1 + .../example/test/widget_test.dart | 30 +++++++++++++ .../example/web/favicon.png | Bin 0 -> 917 bytes .../example/web/icons/Icon-192.png | Bin 0 -> 5292 bytes .../example/web/icons/Icon-512.png | Bin 0 -> 8252 bytes .../example/web/index.html | 42 ++++++++++++++++++ .../example/web/manifest.json | 23 ++++++++++ .../lib/src/google_map.dart | 25 +++-------- .../google_maps_flutter/pubspec.yaml | 4 +- ...oogle_maps_flutter_platform_interface.dart | 17 +++++-- .../method_channel_google_maps_flutter.dart | 40 ++++++++++++++--- 21 files changed, 289 insertions(+), 30 deletions(-) create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/.gitignore create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/android/.gitignore create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/android/app/src/main/kotlin/io/flutter/plugins/example/MainActivity.kt create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/.gitignore create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/AppDelegate.swift create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/Runner-Bridging-Header.h create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/web/favicon.png create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/web/icons/Icon-192.png create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/web/icons/Icon-512.png create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/web/index.html create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json diff --git a/packages/google_maps_flutter/google_maps_flutter/example/.gitignore b/packages/google_maps_flutter/google_maps_flutter/example/.gitignore new file mode 100644 index 000000000000..78b3c2b33643 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/.gitignore @@ -0,0 +1,40 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Exceptions to above rules. +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/packages/google_maps_flutter/google_maps_flutter/example/android/.gitignore b/packages/google_maps_flutter/google_maps_flutter/example/android/.gitignore new file mode 100644 index 000000000000..bc2100d8f75e --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/android/.gitignore @@ -0,0 +1,7 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java diff --git a/packages/google_maps_flutter/google_maps_flutter/example/android/app/src/main/kotlin/io/flutter/plugins/example/MainActivity.kt b/packages/google_maps_flutter/google_maps_flutter/example/android/app/src/main/kotlin/io/flutter/plugins/example/MainActivity.kt new file mode 100644 index 000000000000..5917557e48ab --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/android/app/src/main/kotlin/io/flutter/plugins/example/MainActivity.kt @@ -0,0 +1,12 @@ +package io.flutter.plugins.example + +import androidx.annotation.NonNull; +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugins.GeneratedPluginRegistrant + +class MainActivity: FlutterActivity() { + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + GeneratedPluginRegistrant.registerWith(flutterEngine); + } +} diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/.gitignore b/packages/google_maps_flutter/google_maps_flutter/example/ios/.gitignore new file mode 100644 index 000000000000..e96ef602b8d1 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/.gitignore @@ -0,0 +1,32 @@ +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000000..f9b0d7c5ea15 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000000..f9b0d7c5ea15 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/AppDelegate.swift b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/AppDelegate.swift new file mode 100644 index 000000000000..70693e4a8c12 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/Runner-Bridging-Header.h b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 000000000000..308a2a560b42 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index c7b2c5ff6715..2a3ecc5b4892 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: google_maps_flutter: path: ../ flutter_plugin_android_lifecycle: ^1.0.0 + google_maps: ">=3.0.0 <4.0.0" dev_dependencies: flutter_driver: diff --git a/packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart b/packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart new file mode 100644 index 000000000000..747db1da35e8 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:example/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/packages/google_maps_flutter/google_maps_flutter/example/web/favicon.png b/packages/google_maps_flutter/google_maps_flutter/example/web/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8aaa46ac1ae21512746f852a42ba87e4165dfdd1 GIT binary patch literal 917 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0X7 zltGxWVyS%@P(fs7NJL45ua8x7ey(0(N`6wRUPW#JP&EUCO@$SZnVVXYs8ErclUHn2 zVXFjIVFhG^g!Ppaz)DK8ZIvQ?0~DO|i&7O#^-S~(l1AfjnEK zjFOT9D}DX)@^Za$W4-*MbbUihOG|wNBYh(yU7!lx;>x^|#0uTKVr7USFmqf|i<65o z3raHc^AtelCMM;Vme?vOfh>Xph&xL%(-1c06+^uR^q@XSM&D4+Kp$>4P^%3{)XKjo zGZknv$b36P8?Z_gF{nK@`XI}Z90TzwSQO}0J1!f2c(B=V`5aP@1P1a|PZ!4!3&Gl8 zTYqUsf!gYFyJnXpu0!n&N*SYAX-%d(5gVjrHJWqXQshj@!Zm{!01WsQrH~9=kTxW#6SvuapgMqt>$=j#%eyGrQzr zP{L-3gsMA^$I1&gsBAEL+vxi1*Igl=8#8`5?A-T5=z-sk46WA1IUT)AIZHx1rdUrf zVJrJn<74DDw`j)Ki#gt}mIT-Q`XRa2-jQXQoI%w`nb|XblvzK${ZzlV)m-XcwC(od z71_OEC5Bt9GEXosOXaPTYOia#R4ID2TiU~`zVMl08TV_C%DnU4^+HE>9(CE4D6?Fz oujB08i7adh9xk7*FX66dWH6F5TM;?E2b5PlUHx3vIVCg!0Dx9vYXATM literal 0 HcmV?d00001 diff --git a/packages/google_maps_flutter/google_maps_flutter/example/web/icons/Icon-192.png b/packages/google_maps_flutter/google_maps_flutter/example/web/icons/Icon-192.png new file mode 100644 index 0000000000000000000000000000000000000000..b749bfef07473333cf1dd31e9eed89862a5d52aa GIT binary patch literal 5292 zcmZ`-2T+sGz6~)*FVZ`aW+(v>MIm&M-g^@e2u-B-DoB?qO+b1Tq<5uCCv>ESfRum& zp%X;f!~1{tzL__3=gjVJ=j=J>+nMj%ncXj1Q(b|Ckbw{Y0FWpt%4y%$uD=Z*c-x~o zE;IoE;xa#7Ll5nj-e4CuXB&G*IM~D21rCP$*xLXAK8rIMCSHuSu%bL&S3)8YI~vyp@KBu9Ph7R_pvKQ@xv>NQ`dZp(u{Z8K3yOB zn7-AR+d2JkW)KiGx0hosml;+eCXp6+w%@STjFY*CJ?udJ64&{BCbuebcuH;}(($@@ znNlgBA@ZXB)mcl9nbX#F!f_5Z=W>0kh|UVWnf!At4V*LQP%*gPdCXd6P@J4Td;!Ur z<2ZLmwr(NG`u#gDEMP19UcSzRTL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-r zxZ13G$G<48leNqR!DCVt9)@}(zMI5w6Wo=N zpP1*3DI;~h2WDWgcKn*f!+ORD)f$DZFwgKBafEZmeXQMAsq9sxP9A)7zOYnkHT9JU zRA`umgmP9d6=PHmFIgx=0$(sjb>+0CHG)K@cPG{IxaJ&Ueo8)0RWgV9+gO7+Bl1(F z7!BslJ2MP*PWJ;x)QXbR$6jEr5q3 z(3}F@YO_P1NyTdEXRLU6fp?9V2-S=E+YaeLL{Y)W%6`k7$(EW8EZSA*(+;e5@jgD^I zaJQ2|oCM1n!A&-8`;#RDcZyk*+RPkn_r8?Ak@agHiSp*qFNX)&i21HE?yuZ;-C<3C zwJGd1lx5UzViP7sZJ&|LqH*mryb}y|%AOw+v)yc`qM)03qyyrqhX?ub`Cjwx2PrR! z)_z>5*!*$x1=Qa-0uE7jy0z`>|Ni#X+uV|%_81F7)b+nf%iz=`fF4g5UfHS_?PHbr zB;0$bK@=di?f`dS(j{l3-tSCfp~zUuva+=EWxJcRfp(<$@vd(GigM&~vaYZ0c#BTs z3ijkxMl=vw5AS&DcXQ%eeKt!uKvh2l3W?&3=dBHU=Gz?O!40S&&~ei2vg**c$o;i89~6DVns zG>9a*`k5)NI9|?W!@9>rzJ;9EJ=YlJTx1r1BA?H`LWijk(rTax9(OAu;q4_wTj-yj z1%W4GW&K4T=uEGb+E!>W0SD_C0RR91 literal 0 HcmV?d00001 diff --git a/packages/google_maps_flutter/google_maps_flutter/example/web/icons/Icon-512.png b/packages/google_maps_flutter/google_maps_flutter/example/web/icons/Icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..88cfd48dff1169879ba46840804b412fe02fefd6 GIT binary patch literal 8252 zcmd5=2T+s!lYZ%-(h(2@5fr2dC?F^$C=i-}R6$UX8af(!je;W5yC_|HmujSgN*6?W z3knF*TL1$|?oD*=zPbBVex*RUIKsL<(&Rj9%^UD2IK3W?2j>D?eWQgvS-HLymHo9%~|N2Q{~j za?*X-{b9JRowv_*Mh|;*-kPFn>PI;r<#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`Y%}9mUsjUR%T!?k^(q)6FH6Af^b6 zlPg~IEwg0y;`t9y;#D+uz!oE4VP&Je!<#q*F?m5L5?J3i@!0J6q#eu z!RRU`-)HeqGi_UJZ(n~|PSNsv+Wgl{P-TvaUQ9j?ZCtvb^37U$sFpBrkT{7Jpd?HpIvj2!}RIq zH{9~+gErN2+}J`>Jvng2hwM`=PLNkc7pkjblKW|+Fk9rc)G1R>Ww>RC=r-|!m-u7( zc(a$9NG}w#PjWNMS~)o=i~WA&4L(YIW25@AL9+H9!?3Y}sv#MOdY{bb9j>p`{?O(P zIvb`n?_(gP2w3P#&91JX*md+bBEr%xUHMVqfB;(f?OPtMnAZ#rm5q5mh;a2f_si2_ z3oXWB?{NF(JtkAn6F(O{z@b76OIqMC$&oJ_&S|YbFJ*)3qVX_uNf5b8(!vGX19hsG z(OP>RmZp29KH9Ge2kKjKigUmOe^K_!UXP`von)PR8Qz$%=EmOB9xS(ZxE_tnyzo}7 z=6~$~9k0M~v}`w={AeqF?_)9q{m8K#6M{a&(;u;O41j)I$^T?lx5(zlebpY@NT&#N zR+1bB)-1-xj}R8uwqwf=iP1GbxBjneCC%UrSdSxK1vM^i9;bUkS#iRZw2H>rS<2<$ zNT3|sDH>{tXb=zq7XZi*K?#Zsa1h1{h5!Tq_YbKFm_*=A5-<~j63he;4`77!|LBlo zR^~tR3yxcU=gDFbshyF6>o0bdp$qmHS7D}m3;^QZq9kBBU|9$N-~oU?G5;jyFR7>z hN`IR97YZXIo@y!QgFWddJ3|0`sjFx!m))><{BI=FK%f8s literal 0 HcmV?d00001 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 new file mode 100644 index 000000000000..bf817badbc9a --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/web/index.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + example + + + + + + + + + + + diff --git a/packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json b/packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json new file mode 100644 index 000000000000..c63800102369 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "minimal-ui", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart index f6a413a82ffb..dff999aab10b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart @@ -219,26 +219,11 @@ class _GoogleMapState extends State { 'polylinesToAdd': _serializePolylineSet(widget.polylines), 'circlesToAdd': _serializeCircleSet(widget.circles), }; - if (defaultTargetPlatform == TargetPlatform.android) { - return AndroidView( - viewType: 'plugins.flutter.io/google_maps', - onPlatformViewCreated: onPlatformViewCreated, - gestureRecognizers: widget.gestureRecognizers, - creationParams: creationParams, - creationParamsCodec: const StandardMessageCodec(), - ); - } else if (defaultTargetPlatform == TargetPlatform.iOS) { - return UiKitView( - viewType: 'plugins.flutter.io/google_maps', - onPlatformViewCreated: onPlatformViewCreated, - gestureRecognizers: widget.gestureRecognizers, - creationParams: creationParams, - creationParamsCodec: const StandardMessageCodec(), - ); - } - - return Text( - '$defaultTargetPlatform is not yet supported by the maps plugin'); + return _googleMapsFlutterPlatform.buildView( + creationParams, + widget.gestureRecognizers, + onPlatformViewCreated, + ); } @override diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index ab7a3390369c..636255a6205b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -9,8 +9,8 @@ dependencies: flutter_plugin_android_lifecycle: ^1.0.0 google_maps_flutter_platform_interface: path: ../google_maps_flutter_platform_interface -# google_maps_flutter_web: -# path: ../google_maps_flutter_web + google_maps_flutter_web: + path: ../google_maps_flutter_web dev_dependencies: flutter_test: diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart index 9888c4b6f63b..5cbed251d78b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart @@ -4,8 +4,11 @@ import 'dart:async'; import 'dart:ui'; - +import 'package:flutter/widgets.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; import 'package:meta/meta.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -37,11 +40,11 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { static final Object _token = Object(); static GoogleMapsFlutterPlatform _instance = - MethodChannelGoogleMapsFlutter(0); + MethodChannelGoogleMapsFlutter(); /// The default instance of [GoogleMapsFlutterPlatform] to use. /// - /// Defaults to [MethodChannelUrlLauncher]. + /// Defaults to [MethodChannelGoogleMapsFlutter]. static GoogleMapsFlutterPlatform get instance => _instance; /// Platform-specific plugins should set this with their own platform-specific @@ -213,4 +216,12 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { Future getZoomLevel() { throw UnimplementedError('getZoomLevel() has not been implemented.'); } + + ///TODO + Widget buildView( + Map creationParams, + Set> gestureRecognizers, + PlatformViewCreatedCallback onPlatformViewCreated) { + throw UnimplementedError('buildView() has not been implemented.'); + } } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart index e60e35038f57..262899910324 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/method_channel_google_maps_flutter.dart @@ -4,24 +4,27 @@ import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/gestures.dart'; import 'google_maps_flutter_platform_interface.dart'; MethodChannel _channel; + /// An implementation of [GoogleMapsFlutterPlatform] that uses method channels. class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { - ///Initialize control of a [MethodChannelGoogleMapsFlutter] with [id]. - MethodChannelGoogleMapsFlutter(int id) { - _channel = MethodChannel('plugins.flutter.io/google_maps_$id'); - } + + int _id; /// /// Initializes the platform interface with [id]. /// /// This method is called when the plugin is first initialized. Future init(int id) async { - _channel = MethodChannel('plugins.flutter.io/google_maps_$id'); + this._id = id; + _channel = MethodChannel('plugins.flutter.io/google_maps_$_id'); await _channel.invokeMethod('map#waitForMap'); } @@ -222,4 +225,31 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { await _channel.invokeMethod('map#getZoomLevel'); return zoomLevel; } + + Widget buildView( + Map creationParams, + Set> gestureRecognizers, + PlatformViewCreatedCallback onPlatformViewCreated) { + if (defaultTargetPlatform == TargetPlatform.android) { + return AndroidView( + viewType: 'plugins.flutter.io/google_maps', + onPlatformViewCreated: onPlatformViewCreated, + gestureRecognizers: gestureRecognizers, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + ); + } else if (defaultTargetPlatform == TargetPlatform.iOS) { + return UiKitView( + viewType: 'plugins.flutter.io/google_maps', + onPlatformViewCreated: onPlatformViewCreated, + gestureRecognizers: gestureRecognizers, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + ); + } + return Text( + '$defaultTargetPlatform is not yet supported by the maps plugin'); + } + + } From 73d23a25c98e02b7dfae87df32981f715f961380 Mon Sep 17 00:00:00 2001 From: chung2012 Date: Mon, 9 Mar 2020 09:53:58 +0800 Subject: [PATCH 10/48] update pubspec --- packages/google_maps_flutter/google_maps_flutter/pubspec.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 636255a6205b..a996ede4febf 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -8,9 +8,6 @@ dependencies: sdk: flutter flutter_plugin_android_lifecycle: ^1.0.0 google_maps_flutter_platform_interface: - path: ../google_maps_flutter_platform_interface - google_maps_flutter_web: - path: ../google_maps_flutter_web dev_dependencies: flutter_test: From 25099abf7c7b773ba635f8b69ccee52cdffecbaa Mon Sep 17 00:00:00 2001 From: chung2012 Date: Sat, 21 Mar 2020 00:26:07 +0800 Subject: [PATCH 11/48] bugs fix --- .../google_maps_flutter/example/pubspec.yaml | 2 +- .../example/test/widget_test.dart | 30 ----------- .../example/web/index.html | 9 +--- .../lib/src/controller.dart | 4 +- .../method_channel_google_maps_flutter.dart | 52 +++++++++---------- 5 files changed, 31 insertions(+), 66 deletions(-) delete mode 100644 packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index 2a3ecc5b4892..da8306f90edc 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: google_maps_flutter: path: ../ flutter_plugin_android_lifecycle: ^1.0.0 - google_maps: ">=3.0.0 <4.0.0" + google_maps: ^3.0.0 dev_dependencies: flutter_driver: diff --git a/packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart b/packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart deleted file mode 100644 index 747db1da35e8..000000000000 --- a/packages/google_maps_flutter/google_maps_flutter/example/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:example/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} 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 bf817badbc9a..365abcaaf7dd 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 @@ -16,13 +16,6 @@ example - - - - - - - - - - example - - - - - - - - - - diff --git a/packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json b/packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json deleted file mode 100644 index c63800102369..000000000000 --- a/packages/google_maps_flutter/google_maps_flutter/example/web/manifest.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "example", - "short_name": "example", - "start_url": ".", - "display": "minimal-ui", - "background_color": "#0175C2", - "theme_color": "#0175C2", - "description": "A new Flutter project.", - "orientation": "portrait-primary", - "prefer_related_applications": false, - "icons": [ - { - "src": "icons/Icon-192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "icons/Icon-512.png", - "sizes": "512x512", - "type": "image/png" - } - ] -} From 99346d64c088e38f3ac57622b407d0451e3d877b Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 12:16:49 -0700 Subject: [PATCH 42/48] Remove .gitignore from example dir --- .../google_maps_flutter/example/.gitignore | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 packages/google_maps_flutter/google_maps_flutter/example/.gitignore diff --git a/packages/google_maps_flutter/google_maps_flutter/example/.gitignore b/packages/google_maps_flutter/google_maps_flutter/example/.gitignore deleted file mode 100644 index 78b3c2b33643..000000000000 --- a/packages/google_maps_flutter/google_maps_flutter/example/.gitignore +++ /dev/null @@ -1,40 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Web related -lib/generated_plugin_registrant.dart - -# Symbolication related -app.*.symbols - -# Exceptions to above rules. -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages From f5a601393122b4dffedb6ebc6664fd8284342a96 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 13:59:55 -0700 Subject: [PATCH 43/48] Appease the analyzer. --- .../lib/src/types/bitmap.dart | 3 --- .../lib/src/types/camera.dart | 1 + .../lib/src/types/cap.dart | 1 + .../lib/src/types/circle.dart | 1 + .../lib/src/types/circle_updates.dart | 6 ++++++ .../lib/src/types/location.dart | 2 ++ .../lib/src/types/marker.dart | 1 + .../lib/src/types/marker_updates.dart | 6 ++++++ .../lib/src/types/pattern_item.dart | 1 + .../lib/src/types/polygon.dart | 1 + .../lib/src/types/polygon_updates.dart | 6 ++++++ .../lib/src/types/polyline.dart | 1 + .../lib/src/types/polyline_updates.dart | 5 +++++ .../lib/src/types/screen_coordinate.dart | 1 + .../lib/src/types/ui.dart | 2 ++ 15 files changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart index 0fc07bc9e863..40581b43e065 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart @@ -8,7 +8,6 @@ import 'dart:typed_data' show Uint8List; import 'package:flutter/material.dart' show ImageConfiguration, AssetImage, AssetBundleImageKey; import 'package:flutter/services.dart' show AssetBundle; -import 'package:meta/meta.dart' show visibleForTesting; /// Defines a bitmap image. For a marker, this class can be used to set the /// image of the marker icon. For a ground overlay, it can be used to set the @@ -113,7 +112,5 @@ class BitmapDescriptor { final dynamic _json; /// Convert the object to a Json format. - /// Used for testing only. - @visibleForTesting dynamic toJson() => _json; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart index f9ef3aa9aadb..10ea1e98846a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart @@ -192,5 +192,6 @@ class CameraUpdate { final dynamic _json; + /// Converts this object to something serializable in JSON. dynamic toJson() => _json; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart index 922355a071e6..fa2e08a467a2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart @@ -49,5 +49,6 @@ class Cap { final dynamic _json; + /// Converts this object to something serializable in JSON. dynamic toJson() => _json; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart index c39acd1c41c5..d1418a4c30b1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart @@ -123,6 +123,7 @@ class Circle { /// Creates a new [Circle] object whose values are the same as this instance. Circle clone() => copyWith(); + /// Converts this object to something serializable in JSON. dynamic toJson() { final Map json = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart index 5dd75d7cb40b..6f494423a38f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart @@ -60,10 +60,16 @@ class CircleUpdates { circlesToChange = _circlesToChange; } + /// Set of Circles to be added in this update. Set circlesToAdd; + + /// Set of CircleIds to be removed in this update. Set circleIdsToRemove; + + /// Set of Circles to be changed in this update. Set circlesToChange; + /// Converts this object to something serializable in JSON. Map toJson() { final Map updateMap = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart index 34f78b911c40..f33437856406 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart @@ -27,6 +27,7 @@ class LatLng { /// The longitude in degrees between -180.0 (inclusive) and 180.0 (exclusive). final double longitude; + /// Converts this object to something serializable in JSON. dynamic toJson() { return [latitude, longitude]; } @@ -75,6 +76,7 @@ class LatLngBounds { /// The northeast corner of the rectangle. final LatLng northeast; + /// Converts this object to something serializable in JSON. dynamic toJson() { return [southwest.toJson(), northeast.toJson()]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart index fc8fd1e66031..9b57f9676334 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart @@ -267,6 +267,7 @@ class Marker { /// Creates a new [Marker] object whose values are the same as this instance. Marker clone() => copyWith(); + /// Converts this object to something serializable in JSON. Map toJson() { final Map json = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart index 4add2144e1bc..bb6ea8813ea3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart @@ -60,10 +60,16 @@ class MarkerUpdates { markersToChange = _markersToChange; } + /// Set of Markers to be added in this update. Set markersToAdd; + + /// Set of MarkerIds to be removed in this update. Set markerIdsToRemove; + + /// Set of Markers to be changed in this update. Set markersToChange; + /// Converts this object to something serializable in JSON. Map toJson() { final Map updateMap = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart index 95de941e52dd..28c7ce9d33dd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart @@ -30,5 +30,6 @@ class PatternItem { final dynamic _json; + /// Converts this object to something serializable in JSON. dynamic toJson() => _json; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart index a3e681868297..3b5e25060faf 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart @@ -131,6 +131,7 @@ class Polygon { return copyWith(pointsParam: List.of(points)); } + /// Converts this object to something serializable in JSON. dynamic toJson() { final Map json = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart index 8c69efe2b402..cc8b8e26c896 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart @@ -60,10 +60,16 @@ class PolygonUpdates { polygonsToChange = _polygonsToChange; } + /// Set of Polygons to be added in this update. Set polygonsToAdd; + + /// Set of PolygonIds to be removed in this update. Set polygonIdsToRemove; + + /// Set of Polygons to be changed in this update. Set polygonsToChange; + /// Converts this object to something serializable in JSON. Map toJson() { final Map updateMap = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart index 0798a00930e6..ae5c3b976352 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart @@ -173,6 +173,7 @@ class Polyline { ); } + /// Converts this object to something serializable in JSON. dynamic toJson() { final Map json = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart index df45653840c8..2c986c6e6043 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart @@ -61,8 +61,13 @@ class PolylineUpdates { polylinesToChange = _polylinesToChange; } + /// Set of Polylines to be added in this update. Set polylinesToAdd; + + /// Set of PolylineIds to be removed in this update. Set polylineIdsToRemove; + + /// Set of Polylines to be changed in this update. Set polylinesToChange; Map toJson() { diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart index b9df42a86668..26525a2e8492 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart @@ -24,6 +24,7 @@ class ScreenCoordinate { /// Represents the number of pixels from the top of the [GoogleMap]. final int y; + /// Converts this object to something serializable in JSON. dynamic toJson() { return { "x": x, diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart index 5d895e614b92..8d84171bac03 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart @@ -44,6 +44,7 @@ class CameraTargetBounds { /// Unbounded camera target. static const CameraTargetBounds unbounded = CameraTargetBounds(null); + /// Converts this object to something serializable in JSON. dynamic toJson() => [bounds?.toJson()]; @override @@ -84,6 +85,7 @@ class MinMaxZoomPreference { static const MinMaxZoomPreference unbounded = MinMaxZoomPreference(null, null); + /// Converts this object to something serializable in JSON. dynamic toJson() => [minZoom, maxZoom]; @override From 545500b5646bbb3dda35bdc811c1cfe66253dd23 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 14:48:49 -0700 Subject: [PATCH 44/48] Appease analyze some more. --- .../lib/google_maps_flutter_platform_interface.dart | 4 ++++ .../lib/src/events/map_event.dart | 4 ++++ .../lib/src/types/cap.dart | 1 + .../lib/src/types/location.dart | 1 + .../lib/src/types/polyline_updates.dart | 1 + .../lib/src/types/screen_coordinate.dart | 1 + .../lib/src/types/types.dart | 5 ++++- .../lib/src/types/utils/circle.dart | 6 ++++++ .../lib/src/types/utils/marker.dart | 6 ++++++ .../lib/src/types/utils/polygon.dart | 6 ++++++ .../lib/src/types/utils/polyline.dart | 6 ++++++ 11 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart index 3e2104434c9b..cb28b40470fd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/google_maps_flutter_platform_interface.dart @@ -1,3 +1,7 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + export 'src/platform_interface/google_maps_flutter_platform.dart'; export 'src/types/types.dart'; export 'src/events/map_event.dart'; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart index afc2c18d883f..e597be4d6213 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart @@ -1,3 +1,7 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; /// Basic event coming from the native side of Maps. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart index fa2e08a467a2..68bf14c36408 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart @@ -1,6 +1,7 @@ // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + import 'package:meta/meta.dart' show immutable; import 'types.dart'; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart index f33437856406..6b76a6d496ac 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart @@ -1,6 +1,7 @@ // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + import 'dart:ui' show hashValues; import 'package:meta/meta.dart'; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart index 2c986c6e6043..f871928c0ac4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart @@ -70,6 +70,7 @@ class PolylineUpdates { /// Set of Polylines to be changed in this update. Set polylinesToChange; + /// Converts this object to something serializable in JSON. Map toJson() { final Map updateMap = {}; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart index 26525a2e8492..965db7969bc2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart @@ -1,6 +1,7 @@ // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + import 'dart:ui' show hashValues; import 'package:meta/meta.dart' show immutable, required; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/types.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/types.dart index 0b13637ded74..e56c3a5dd646 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/types.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/types.dart @@ -1,5 +1,8 @@ -// All the public types exposed by this package. +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// All the public types exposed by this package. export 'bitmap.dart'; export 'callbacks.dart'; export 'camera.dart'; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/circle.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/circle.dart index 139af16adf43..5c3af96f8e02 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/circle.dart @@ -1,5 +1,10 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import '../types.dart'; +/// Converts an [Iterable] of Circles in a Map of CircleId -> Circle. Map keyByCircleId(Iterable circles) { if (circles == null) { return {}; @@ -8,6 +13,7 @@ Map keyByCircleId(Iterable circles) { MapEntry(circle.circleId, circle.clone()))); } +/// Converts a Set of Circles into something serializable in JSON. List> serializeCircleSet(Set circles) { if (circles == null) { return null; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/marker.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/marker.dart index 62a2d115fe48..7a2c76d8055b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/marker.dart @@ -1,5 +1,10 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import '../types.dart'; +/// Converts an [Iterable] of Markers in a Map of MarkerId -> Marker. Map keyByMarkerId(Iterable markers) { if (markers == null) { return {}; @@ -8,6 +13,7 @@ Map keyByMarkerId(Iterable markers) { MapEntry(marker.markerId, marker.clone()))); } +/// Converts a Set of Markers into something serializable in JSON. List> serializeMarkerSet(Set markers) { if (markers == null) { return null; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polygon.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polygon.dart index b865358af99b..9434ddaa077d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polygon.dart @@ -1,5 +1,10 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import '../types.dart'; +/// Converts an [Iterable] of Polygons in a Map of PolygonId -> Polygon. Map keyByPolygonId(Iterable polygons) { if (polygons == null) { return {}; @@ -8,6 +13,7 @@ Map keyByPolygonId(Iterable polygons) { MapEntry(polygon.polygonId, polygon.clone()))); } +/// Converts a Set of Polygons into something serializable in JSON. List> serializePolygonSet(Set polygons) { if (polygons == null) { return null; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polyline.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polyline.dart index 3f7256143988..9cef6319ddb5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/polyline.dart @@ -1,5 +1,10 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import '../types.dart'; +/// Converts an [Iterable] of Polylines in a Map of PolylineId -> Polyline. Map keyByPolylineId(Iterable polylines) { if (polylines == null) { return {}; @@ -9,6 +14,7 @@ Map keyByPolylineId(Iterable polylines) { polyline.polylineId, polyline.clone()))); } +/// Converts a Set of Polylines into something serializable in JSON. List> serializePolylineSet(Set polylines) { if (polylines == null) { return null; From 609200f26f90d88c7892a2696f5724a1329c09b2 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 15:03:53 -0700 Subject: [PATCH 45/48] Rename _controller to _mapEventStreamController --- .../method_channel_google_maps_flutter.dart | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart index 7273f04b2732..1c8f995c6c12 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart @@ -44,12 +44,12 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { // // It is a `broadcast` because multiple controllers will connect to // different stream views of this Controller. - final StreamController _controller = + final StreamController _mapEventStreamController = StreamController.broadcast(); // Returns a filtered view of the events in the _controller, by mapId. Stream _events(int mapId) => - _controller.stream.where((event) => event.mapId == mapId); + _mapEventStreamController.stream.where((event) => event.mapId == mapId); @override Stream onCameraMoveStarted({@required int mapId}) { @@ -109,62 +109,62 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { Future _handleMethodCall(MethodCall call, int mapId) async { switch (call.method) { case 'camera#onMoveStarted': - _controller.add(CameraMoveStartedEvent(mapId)); + _mapEventStreamController.add(CameraMoveStartedEvent(mapId)); break; case 'camera#onMove': - _controller.add(CameraMoveEvent( + _mapEventStreamController.add(CameraMoveEvent( mapId, CameraPosition.fromMap(call.arguments['position']), )); break; case 'camera#onIdle': - _controller.add(CameraIdleEvent(mapId)); + _mapEventStreamController.add(CameraIdleEvent(mapId)); break; case 'marker#onTap': - _controller.add(MarkerTapEvent( + _mapEventStreamController.add(MarkerTapEvent( mapId, MarkerId(call.arguments['markerId']), )); break; case 'marker#onDragEnd': - _controller.add(MarkerDragEndEvent( + _mapEventStreamController.add(MarkerDragEndEvent( mapId, LatLng.fromJson(call.arguments['position']), MarkerId(call.arguments['markerId']), )); break; case 'infoWindow#onTap': - _controller.add(InfoWindowTapEvent( + _mapEventStreamController.add(InfoWindowTapEvent( mapId, MarkerId(call.arguments['markerId']), )); break; case 'polyline#onTap': - _controller.add(PolylineTapEvent( + _mapEventStreamController.add(PolylineTapEvent( mapId, PolylineId(call.arguments['polylineId']), )); break; case 'polygon#onTap': - _controller.add(PolygonTapEvent( + _mapEventStreamController.add(PolygonTapEvent( mapId, PolygonId(call.arguments['polygonId']), )); break; case 'circle#onTap': - _controller.add(CircleTapEvent( + _mapEventStreamController.add(CircleTapEvent( mapId, CircleId(call.arguments['circleId']), )); break; case 'map#onTap': - _controller.add(MapTapEvent( + _mapEventStreamController.add(MapTapEvent( mapId, LatLng.fromJson(call.arguments['position']), )); break; case 'map#onLongPress': - _controller.add(MapLongPressEvent( + _mapEventStreamController.add(MapLongPressEvent( mapId, LatLng.fromJson(call.arguments['position']), )); From a3efd0fb785f69da4fb3610f64a63170d5a3ddab Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 16:14:40 -0700 Subject: [PATCH 46/48] Update some docs on the platform --- .../google_maps_flutter_platform.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart index 8f1e9fc28379..b89d3420c68e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart @@ -15,13 +15,14 @@ import 'package:google_maps_flutter_platform_interface/src/method_channel/method import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -/// The interface that implementations of google_maps_flutter must implement. +/// The interface that platform-specific implementations of `google_maps_flutter` must extend. /// -/// Platform implementations should extend this class rather than implement it as `google_maps_flutter` -/// does not consider newly added methods to be breaking changes. Extending this class -/// (using `extends`) ensures that the subclass will get the default implementation, while -/// platform implementations that `implements` this interface will be broken by newly added -/// [GoogleMapsFlutterPlatform] methods. +/// Avoid `implements` of this interface. Using `implements` makes adding any new +/// methods here a breaking change for end users of your platform! +/// +/// Do `extends GoogleMapsFlutterPlatform` instead, so new methods added here are +/// inherited in your code with the default implementation (that throws at runtime), +/// rather than breaking your users at compile time. abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// Constructs a GoogleMapsFlutterPlatform. GoogleMapsFlutterPlatform() : super(token: _token); @@ -146,9 +147,6 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// style is left unchanged. /// /// The style string can be generated using [map style tool](https://mapstyle.withgoogle.com/). - /// Also, refer [iOS](https://developers.google.com/maps/documentation/ios-sdk/style-reference) - /// and [Android](https://developers.google.com/maps/documentation/android-sdk/style-reference) - /// style reference for more information regarding the supported styles. Future setMapStyle( String mapStyle, { @required int mapId, From 98e09524d0731f1fd73e7b495b336d5edb707956 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 16:28:18 -0700 Subject: [PATCH 47/48] Document MapEvent constructors. --- .../lib/src/events/map_event.dart | 88 +++++++++++++++---- 1 file changed, 73 insertions(+), 15 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart index e597be4d6213..c462b4b182e2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/events/map_event.dart @@ -3,10 +3,37 @@ // found in the LICENSE file. import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'package:google_maps_flutter_platform_interface/src/method_channel/method_channel_google_maps_flutter.dart'; -/// Basic event coming from the native side of Maps. +/// Generic Event coming from the native side of Maps. /// -/// All MapEvents contain the `mapId` that originated the event. +/// All MapEvents contain the `mapId` that originated the event. This should +/// never be `null`. +/// +/// The `` on this event represents the type of the `value` that is +/// contained within the event. +/// +/// This class is used as a base class for all the events that might be +/// triggered from a Map, but it is never used directly as an event type. +/// +/// Do NOT instantiate new events like `MapEvent(mapId, val)` directly, +/// use a specific class instead: +/// +/// Do `class NewEvent extend MapEvent` when creating your own events. +/// See below for examples: `CameraMoveStartedEvent`, `MarkerDragEndEvent`... +/// These events are more semantic and pleasant to use than raw generics. They +/// can be (and in fact, are) filtered by the `instanceof`-operator. +/// +/// (See [MethodChannelGoogleMapsFlutter.onCameraMoveStarted], for example) +/// +/// If your event needs a `position`, alongside the `value`, do +/// `extends _PositionedMapEvent` instead. This adds a `LatLng position` +/// attribute. +/// +/// If your event *only* needs a `position`, do `extend _PositionedMapEvent` +/// do NOT `extend MapEvent`. The former lets consumers of these +/// events to access the `.position` property, rather than the more generic `.value` +/// yielded from the latter. class MapEvent { /// The ID of the Map this event is associated to. final int mapId; @@ -14,7 +41,10 @@ class MapEvent { /// The value wrapped by this event final T value; - /// Constructor + /// Build a Map Event, that relates a mapId with a given value. + /// + /// The `mapId` is the id of the map that triggered the event. + /// `value` may be `null` in events that don't transport any meaningful data. MapEvent(this.mapId, this.value); } @@ -23,73 +53,101 @@ class _PositionedMapEvent extends MapEvent { /// The position where this event happened. final LatLng position; - /// Constructor + /// Build a Positioned MapEvent, that relates a mapId and a position with a value. + /// + /// The `mapId` is the id of the map that triggered the event. + /// `value` may be `null` in events that don't transport any meaningful data. _PositionedMapEvent(int mapId, this.position, T value) : super(mapId, value); } +// The following events are the ones exposed to the end user. They are semantic extensions +// of the two base classes above. +// +// These events are used to create the appropriate [Stream] objects, with information +// coming from the native side. + /// An event fired when the Camera of a [mapId] starts moving. class CameraMoveStartedEvent extends MapEvent { - /// Constructor + /// Build a CameraMoveStarted Event triggered from the map represented by `mapId`. CameraMoveStartedEvent(int mapId) : super(mapId, null); } /// An event fired while the Camera of a [mapId] moves. class CameraMoveEvent extends MapEvent { - /// Constructor + /// Build a CameraMove Event triggered from the map represented by `mapId`. + /// + /// The `value` of this event is a [CameraPosition] object with the current position of the Camera. CameraMoveEvent(int mapId, CameraPosition position) : super(mapId, position); } /// An event fired when the Camera of a [mapId] becomes idle. class CameraIdleEvent extends MapEvent { - /// Constructor + /// Build a CameraIdle Event triggered from the map represented by `mapId`. CameraIdleEvent(int mapId) : super(mapId, null); } /// An event fired when a [Marker] is tapped. class MarkerTapEvent extends MapEvent { - /// Constructor + /// Build a MarkerTap Event triggered from the map represented by `mapId`. + /// + /// The `value` of this event is a [MarkerId] object that represents the tapped Marker. MarkerTapEvent(int mapId, MarkerId markerId) : super(mapId, markerId); } /// An event fired when an [InfoWindow] is tapped. class InfoWindowTapEvent extends MapEvent { - /// Constructor + /// Build an InfoWindowTap Event triggered from the map represented by `mapId`. + /// + /// The `value` of this event is a [MarkerId] object that represents the tapped InfoWindow. InfoWindowTapEvent(int mapId, MarkerId markerId) : super(mapId, markerId); } /// An event fired when a [Marker] is dragged to a new [LatLng]. class MarkerDragEndEvent extends _PositionedMapEvent { - /// Constructor + /// Build a MarkerDragEnd Event triggered from the map represented by `mapId`. + /// + /// The `position` on this event is the [LatLng] on which the Marker was dropped. + /// The `value` of this event is a [MarkerId] object that represents the moved Marker. MarkerDragEndEvent(int mapId, LatLng position, MarkerId markerId) : super(mapId, position, markerId); } /// An event fired when a [Polyline] is tapped. class PolylineTapEvent extends MapEvent { - /// Constructor + /// Build an PolylineTap Event triggered from the map represented by `mapId`. + /// + /// The `value` of this event is a [PolylineId] object that represents the tapped Polyline. PolylineTapEvent(int mapId, PolylineId polylineId) : super(mapId, polylineId); } /// An event fired when a [Polygon] is tapped. class PolygonTapEvent extends MapEvent { - /// Constructor + /// Build an PolygonTap Event triggered from the map represented by `mapId`. + /// + /// The `value` of this event is a [PolygonId] object that represents the tapped Polygon. PolygonTapEvent(int mapId, PolygonId polygonId) : super(mapId, polygonId); } /// An event fired when a [Circle] is tapped. class CircleTapEvent extends MapEvent { - /// Constructor + /// Build an CircleTap Event triggered from the map represented by `mapId`. + /// + /// The `value` of this event is a [CircleId] object that represents the tapped Circle. CircleTapEvent(int mapId, CircleId circleId) : super(mapId, circleId); } /// An event fired when a Map is tapped. class MapTapEvent extends _PositionedMapEvent { - /// Constructor + /// Build an MapTap Event triggered from the map represented by `mapId`. + /// + /// The `position` of this event is the LatLng where the Map was tapped. MapTapEvent(int mapId, LatLng position) : super(mapId, position, null); } /// An event fired when a Map is long pressed. class MapLongPressEvent extends _PositionedMapEvent { - /// Constructor + /// Build an MapTap Event triggered from the map represented by `mapId`. + /// + /// The `position` of this event is the LatLng where the Map was long pressed. MapLongPressEvent(int mapId, LatLng position) : super(mapId, position, null); } From 5057b0abca700f046b7550fc18624d689d45f382 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 3 Apr 2020 17:53:32 -0700 Subject: [PATCH 48/48] Document method_channel class --- .../method_channel_google_maps_flutter.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart index 1c8f995c6c12..edbc51ab5afd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart @@ -13,7 +13,16 @@ import 'package:flutter/gestures.dart'; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; import 'package:stream_transform/stream_transform.dart'; -/// An implementation of [GoogleMapsFlutterPlatform] that uses method channels. +/// An implementation of [GoogleMapsFlutterPlatform] that uses [MethodChannel] to communicate with the native code. +/// +/// The `google_maps_flutter` plugin code itself never talks to the native code directly. It delegates +/// all those calls to an instance of a class that extends the GoogleMapsFlutterPlatform. +/// +/// The architecture above allows for platforms that communicate differently with the native side +/// (like web) to have a common interface to extend. +/// +/// This is the instance that runs when the native side talks to your Flutter app through MethodChannels, +/// like the Android and iOS platforms. class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { // Keep a collection of id -> channel // Every method call passes the int mapId