From c72d91e445cc6e6964234114da7e01d4cf3d1923 Mon Sep 17 00:00:00 2001 From: jose Date: Fri, 31 May 2019 12:14:56 +0200 Subject: [PATCH 1/2] [google_maps_flutter] Adds support for add padding to the map --- .../plugins/googlemaps/GoogleMapController.java | 10 ++++++++++ .../ios/Classes/GoogleMapController.m | 9 ++++++++- .../google_maps_flutter/lib/src/controller.dart | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java index 31f532a1d18b..0649a41f259e 100644 --- a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java +++ b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java @@ -219,6 +219,16 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { } break; } + case "map#setPadding": + { + double left = call.argument("left"); + double top = call.argument("top"); + double right = call.argument("right"); + double bottom = call.argument("bottom"); + googleMap.setPadding((int)(left * density), (int)(top * density), (int) (right * density), (int) (bottom * density)); + result.success(null); + break; + } case "camera#move": { final CameraUpdate cameraUpdate = diff --git a/packages/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/ios/Classes/GoogleMapController.m index fa496387bc2c..d6691cf2ecc9 100644 --- a/packages/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -133,7 +133,14 @@ - (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if ([call.method isEqualToString:@"camera#move"]) { [self moveWithCameraUpdate:ToCameraUpdate(call.arguments[@"cameraUpdate"])]; result(nil); - } else if ([call.method isEqualToString:@"map#update"]) { + } else if ([call.method isEqualToString:@"map#setPadding"]) { + float top = [FLTGoogleMapJsonConversions toFloat:call.arguments[@"top"]]; + float left = [FLTGoogleMapJsonConversions toFloat:call.arguments[@"left"]]; + float bottom = [FLTGoogleMapJsonConversions toFloat:call.arguments[@"bottom"]]; + float right = [FLTGoogleMapJsonConversions toFloat:call.arguments[@"right"]]; + _mapView.padding = UIEdgeInsetsMake(top, left, bottom, right); + result(nil); + } else if ([call.method isEqualToString:@"map#update"]) { InterpretMapOptions(call.arguments[@"options"], self); result(PositionToJson([self cameraPosition])); } else if ([call.method isEqualToString:@"map#getVisibleRegion"]) { diff --git a/packages/google_maps_flutter/lib/src/controller.dart b/packages/google_maps_flutter/lib/src/controller.dart index b3f3990416f5..28414c98d0ed 100644 --- a/packages/google_maps_flutter/lib/src/controller.dart +++ b/packages/google_maps_flutter/lib/src/controller.dart @@ -209,4 +209,20 @@ class GoogleMapController { return LatLngBounds(northeast: northeast, southwest: southwest); } + + /// Sets padding on the map + /// + /// The returned [Future] completes after the change has been made on the + /// platform side. + Future setPadding(double left, double top, double right, double bottom) async { + // TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter. + // https://github.com/flutter/flutter/issues/26431 + // ignore: strong_mode_implicit_dynamic_method + await channel.invokeMethod('map#setPadding', { + 'top': top, + 'left': left, + 'bottom': bottom, + 'right': right, + }); + } } From 9ca056a99cac626297d3fff8c41716d95b274502 Mon Sep 17 00:00:00 2001 From: Debkanchan Samadder Date: Fri, 7 Jun 2019 21:04:00 +0530 Subject: [PATCH 2/2] Update pubspec.yaml Look man I'm desperate for the padding implementation that's why I'm opening these stupid Pull Requests I've been watching this from when you opened the PR please merge these changes (if it possibly fixes them) --- packages/google_maps_flutter/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index 9af1da63c62d..aa97ad91cc87 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter -version: 0.5.15 +version: 0.5.17 dependencies: flutter: @@ -27,4 +27,4 @@ flutter: environment: sdk: ">=2.0.0-dev.47.0 <3.0.0" - flutter: ">=0.11.9 <2.0.0" + flutter: ">=1.5.0 <2.0.0"