diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsGroundOverlayControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsGroundOverlayControllerTests.m index 7c2a7d76163..93384adb0e9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsGroundOverlayControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsGroundOverlayControllerTests.m @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import +#import + @import google_maps_flutter_ios; @import google_maps_flutter_ios.Test; @import XCTest; @import GoogleMaps; - -#import - #import -#import + #import "PartiallyMockedMapView.h" @interface GoogleMapsGroundOverlayControllerTests : XCTestCase diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.h index c455de65104..ad4b41b7164 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import +#import +#import #import #import @@ -54,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN /// Returns true if a ground overlay with the given identifier exists on the map. - (bool)hasGroundOverlaysWithIdentifier:(NSString *)identifier; -/// Returns FGMPlatformGroundOverlay for identifier. +/// Returns the ground overlay with the given identifier. - (nullable FGMPlatformGroundOverlay *)groundOverlayWithIdentifier:(NSString *)identifier; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m index 5ad77a94e1a..4d270099c65 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m @@ -5,10 +5,41 @@ #import "FGMImageUtils.h" #import "Foundation/Foundation.h" -static UIImage *scaleImage(UIImage *image, double scale); +/// This method is deprecated within the context of `BitmapDescriptor.fromBytes` handling in the +/// flutter google_maps_flutter_platform_interface package which has been replaced by 'bytes' +/// message handling. It will be removed when the deprecated image bitmap description type +/// 'fromBytes' is removed from the platform interface. +static UIImage *scaledImage(UIImage *image, double scale); + +/// Creates a scaled version of the provided UIImage based on a specified scale factor. If the +/// scale factor differs from the image's current scale by more than a small epsilon-delta (to +/// account for minor floating-point inaccuracies), a new UIImage object is created with the +/// specified scale. Otherwise, the original image is returned. +/// +/// @param image The UIImage to scale. +/// @param scale The factor by which to scale the image. +/// @return UIImage Returns the scaled UIImage. static UIImage *scaledImageWithScale(UIImage *image, CGFloat scale); + +/// Scales an input UIImage to a specified size. If the aspect ratio of the input image +/// closely matches the target size, indicated by a small epsilon-delta, the image's scale +/// property is updated instead of resizing the image. If the aspect ratios differ beyond this +/// threshold, the method redraws the image at the target size. +/// +/// @param image The UIImage to scale. +/// @param size The target CGSize to scale the image to. +/// @return UIImage Returns the scaled UIImage. static UIImage *scaledImageWithSize(UIImage *image, CGSize size); -static UIImage *scaledImage(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale); + +/// Scales an input UIImage to a specified width and height preserving aspect ratio if both +/// widht and height are not given.. +/// +/// @param image The UIImage to scale. +/// @param width The target width to scale the image to. +/// @param height The target height to scale the image to. +/// @param screenScale The current screen scale. +/// @return UIImage Returns the scaled UIImage. +static UIImage *scaledImageWithWidthHeight(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale); UIImage *FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, NSObject *registrar, CGFloat screenScale) { @@ -39,7 +70,7 @@ // Refer to the flutter google_maps_flutter_platform_interface package for details. FGMPlatformBitmapAssetImage *bitmapAssetImage = bitmap; image = [UIImage imageNamed:[registrar lookupKeyForAsset:bitmapAssetImage.name]]; - image = scaleImage(image, bitmapAssetImage.scale); + image = scaledImage(image, bitmapAssetImage.scale); } else if ([bitmap isKindOfClass:[FGMPlatformBitmapBytes class]]) { // Deprecated: This message handling for 'fromBytes' has been replaced by 'bytes'. // Refer to the flutter google_maps_flutter_platform_interface package for details. @@ -62,7 +93,7 @@ NSNumber *height = bitmapAssetMap.height; if (width || height) { image = scaledImageWithScale(image, screenScale); - image = scaledImage(image, width, height, screenScale); + image = scaledImageWithWidthHeight(image, width, height, screenScale); } else { image = scaledImageWithScale(image, bitmapAssetMap.imagePixelRatio); } @@ -80,7 +111,7 @@ if (width || height) { // Before scaling the image, image must be in screenScale. image = scaledImageWithScale(image, screenScale); - image = scaledImage(image, width, height, screenScale); + image = scaledImageWithWidthHeight(image, width, height, screenScale); } else { image = scaledImageWithScale(image, bitmapBytesMap.imagePixelRatio); } @@ -98,11 +129,7 @@ return image; } -/// This method is deprecated within the context of `BitmapDescriptor.fromBytes` handling in the -/// flutter google_maps_flutter_platform_interface package which has been replaced by 'bytes' -/// message handling. It will be removed when the deprecated image bitmap description type -/// 'fromBytes' is removed from the platform interface. -UIImage *scaleImage(UIImage *image, double scale) { +UIImage *scaledImage(UIImage *image, double scale) { if (fabs(scale - 1) > 1e-3) { return [UIImage imageWithCGImage:[image CGImage] scale:(image.scale * scale) @@ -111,14 +138,6 @@ return image; } -/// Creates a scaled version of the provided UIImage based on a specified scale factor. If the -/// scale factor differs from the image's current scale by more than a small epsilon-delta (to -/// account for minor floating-point inaccuracies), a new UIImage object is created with the -/// specified scale. Otherwise, the original image is returned. -/// -/// @param image The UIImage to scale. -/// @param scale The factor by which to scale the image. -/// @return UIImage Returns the scaled UIImage. UIImage *scaledImageWithScale(UIImage *image, CGFloat scale) { if (fabs(scale - image.scale) > DBL_EPSILON) { return [UIImage imageWithCGImage:[image CGImage] @@ -128,14 +147,6 @@ return image; } -/// Scales an input UIImage to a specified size. If the aspect ratio of the input image -/// closely matches the target size, indicated by a small epsilon-delta, the image's scale -/// property is updated instead of resizing the image. If the aspect ratios differ beyond this -/// threshold, the method redraws the image at the target size. -/// -/// @param image The UIImage to scale. -/// @param size The target CGSize to scale the image to. -/// @return UIImage Returns the scaled UIImage. UIImage *scaledImageWithSize(UIImage *image, CGSize size) { CGFloat originalPixelWidth = image.size.width * image.scale; CGFloat originalPixelHeight = image.size.height * image.scale; @@ -177,15 +188,7 @@ } } -/// Scales an input UIImage to a specified width and height preserving aspect ratio if both -/// widht and height are not given.. -/// -/// @param image The UIImage to scale. -/// @param width The target width to scale the image to. -/// @param height The target height to scale the image to. -/// @param screenScale The current screen scale. -/// @return UIImage Returns the scaled UIImage. -UIImage *scaledImage(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale) { +UIImage *scaledImageWithWidthHeight(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale) { if (!width && !height) { return image; } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index 8b3a644eec6..79177348a42 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -118,12 +118,12 @@ GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { NSNumber *zoomLevel) { /// Dummy image is used as image is required field of FGMPlatformGroundOverlay and converting /// image back to bitmap image is not currently supported. - FGMPlatformBitmap *mockImage = + FGMPlatformBitmap *placeholderImage = [FGMPlatformBitmap makeWithBitmap:[FGMPlatformBitmapDefaultMarker makeWithHue:0]]; if (isCreatedWithBounds) { return [FGMPlatformGroundOverlay makeWithGroundOverlayId:overlayId - image:mockImage + image:placeholderImage position:nil bounds:[FGMPlatformLatLngBounds makeWithNortheast:[FGMPlatformLatLng @@ -148,7 +148,7 @@ GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { } else { return [FGMPlatformGroundOverlay makeWithGroundOverlayId:overlayId - image:mockImage + image:placeholderImage position:[FGMPlatformLatLng makeWithLatitude:groundOverlay.position.latitude longitude:groundOverlay.position.longitude]