diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/ExtractIconFromDataTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/ExtractIconFromDataTests.m index 01e4f07a5bd5..73e9e11575c0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/ExtractIconFromDataTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/ExtractIconFromDataTests.m @@ -31,9 +31,9 @@ - (void)testExtractIconFromDataAssetAuto { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); + XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); XCTAssertEqual(resultImage.size.width, 1.0); @@ -58,9 +58,8 @@ - (void)testExtractIconFromDataAssetAutoWithScale { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 10); @@ -88,9 +87,8 @@ - (void)testExtractIconFromDataAssetAutoAndSizeWithSameAspectRatio { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(testImage.scale, 1.0); @@ -123,9 +121,8 @@ - (void)testExtractIconFromDataAssetAutoAndSizeWithDifferentAspectRatio { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, screenScale); XCTAssertEqual(resultImage.size.width, width); @@ -150,9 +147,8 @@ - (void)testExtractIconFromDataAssetNoScaling { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); @@ -177,9 +173,8 @@ - (void)testExtractIconFromDataBytesAuto { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); @@ -204,9 +199,8 @@ - (void)testExtractIconFromDataBytesAutoWithScaling { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 10); XCTAssertEqual(resultImage.size.width, 0.1); @@ -232,9 +226,8 @@ - (void)testExtractIconFromDataBytesAutoAndSizeWithSameAspectRatio { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(testImage.scale, 1.0); @@ -267,9 +260,8 @@ - (void)testExtractIconFromDataBytesAutoAndSizeWithDifferentAspectRatio { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, screenScale); XCTAssertEqual(resultImage.size.width, width); @@ -293,9 +285,8 @@ - (void)testExtractIconFromDataBytesNoScaling { CGFloat screenScale = 3.0; - UIImage *resultImage = [FGMUtils iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = + FGMIconFromBitmap([FGMPlatformBitmap makeWithBitmap:bitmap], mockRegistrar, screenScale); XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); XCTAssertEqual(resultImage.size.width, 1.0); @@ -305,43 +296,43 @@ - (void)testExtractIconFromDataBytesNoScaling { - (void)testIsScalableWithScaleFactorFromSize100x100to10x100 { CGSize originalSize = CGSizeMake(100.0, 100.0); CGSize targetSize = CGSizeMake(10.0, 100.0); - XCTAssertFalse([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertFalse(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (void)testIsScalableWithScaleFactorFromSize100x100to10x10 { CGSize originalSize = CGSizeMake(100.0, 100.0); CGSize targetSize = CGSizeMake(10.0, 10.0); - XCTAssertTrue([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertTrue(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (void)testIsScalableWithScaleFactorFromSize233x200to23x20 { CGSize originalSize = CGSizeMake(233.0, 200.0); CGSize targetSize = CGSizeMake(23.0, 20.0); - XCTAssertTrue([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertTrue(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (void)testIsScalableWithScaleFactorFromSize233x200to22x20 { CGSize originalSize = CGSizeMake(233.0, 200.0); CGSize targetSize = CGSizeMake(22.0, 20.0); - XCTAssertFalse([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertFalse(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (void)testIsScalableWithScaleFactorFromSize200x233to20x23 { CGSize originalSize = CGSizeMake(200.0, 233.0); CGSize targetSize = CGSizeMake(20.0, 23.0); - XCTAssertTrue([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertTrue(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (void)testIsScalableWithScaleFactorFromSize200x233to20x22 { CGSize originalSize = CGSizeMake(200.0, 233.0); CGSize targetSize = CGSizeMake(20.0, 22.0); - XCTAssertFalse([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertFalse(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (void)testIsScalableWithScaleFactorFromSize1024x768to500x250 { CGSize originalSize = CGSizeMake(1024.0, 768.0); CGSize targetSize = CGSizeMake(500.0, 250.0); - XCTAssertFalse([FGMUtils isScalableWithScaleFactorFromSize:originalSize toSize:targetSize]); + XCTAssertFalse(FGMIsScalableWithScaleFactorFromSize(originalSize, targetSize)); } - (UIImage *)createOnePixelImage { 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 7e85c56bf1c1..7c2a7d76163d 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 @@ -7,8 +7,9 @@ @import XCTest; @import GoogleMaps; -#import #import + +#import #import #import "PartiallyMockedMapView.h" @@ -18,10 +19,10 @@ @interface GoogleMapsGroundOverlayControllerTests : XCTestCase @implementation GoogleMapsGroundOverlayControllerTests /// Returns GoogleMapGroundOverlayController object instantiated with position and a mocked map -/// instance +/// instance. /// /// @return An object of FLTGoogleMapGroundOverlayController -- (FGMGroundOverlayController *)groundOverlayControllerWithPositionWithMockedMap { ++ (FGMGroundOverlayController *)groundOverlayControllerWithPositionWithMockedMap { NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"widegamut" ofType:@"png" inDirectory:@"assets"]; @@ -46,10 +47,10 @@ - (FGMGroundOverlayController *)groundOverlayControllerWithPositionWithMockedMap } /// Returns GoogleMapGroundOverlayController object instantiated with bounds and a mocked map -/// instance +/// instance. /// /// @return An object of FLTGoogleMapGroundOverlayController -- (FGMGroundOverlayController *)groundOverlayControllerWithBoundsWithMockedMap { ++ (FGMGroundOverlayController *)groundOverlayControllerWithBoundsWithMockedMap { NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"widegamut" ofType:@"png" inDirectory:@"assets"]; @@ -76,7 +77,7 @@ - (FGMGroundOverlayController *)groundOverlayControllerWithBoundsWithMockedMap { - (void)testUpdatingGroundOverlayWithPosition { FGMGroundOverlayController *groundOverlayController = - [self groundOverlayControllerWithPositionWithMockedMap]; + [GoogleMapsGroundOverlayControllerTests groundOverlayControllerWithPositionWithMockedMap]; FGMPlatformLatLng *position = [FGMPlatformLatLng makeWithLatitude:52.4816 longitude:3.1791]; @@ -111,7 +112,7 @@ - (void)testUpdatingGroundOverlayWithPosition { - (void)testUpdatingGroundOverlayWithBounds { FGMGroundOverlayController *groundOverlayController = - [self groundOverlayControllerWithBoundsWithMockedMap]; + [GoogleMapsGroundOverlayControllerTests groundOverlayControllerWithBoundsWithMockedMap]; FGMPlatformLatLngBounds *bounds = [FGMPlatformLatLngBounds makeWithNortheast:[FGMPlatformLatLng makeWithLatitude:54.4816 longitude:5.1791] 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 b8e479406a7a..c455de651041 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 @@ -7,22 +7,24 @@ #import "messages.g.h" +NS_ASSUME_NONNULL_BEGIN + /// Controller of a single ground overlay on the map. @interface FGMGroundOverlayController : NSObject /// The ground overlay this controller handles. -@property(strong, nonatomic) GMSGroundOverlay *_Nonnull groundOverlay; +@property(strong, nonatomic) GMSGroundOverlay *groundOverlay; /// Whether ground overlay is created with bounds or position. -@property(nonatomic, assign) BOOL isCreatedWithBounds; +@property(nonatomic, assign, getter=isCreatedWithBounds) BOOL createdWithBounds; /// Zoom level when ground overlay is initialized with position. @property(nonatomic, strong, nullable) NSNumber *zoomLevel; /// Initializes an instance of this class with a GMSGroundOverlay, a map view, and identifier. -- (instancetype _Nullable)initWithGroundOverlay:(GMSGroundOverlay *_Nonnull)groundOverlay - identifier:(NSString *_Nonnull)identifier - mapView:(GMSMapView *_Nonnull)mapView +- (instancetype _Nullable)initWithGroundOverlay:(GMSGroundOverlay *)groundOverlay + identifier:(NSString *)identifier + mapView:(GMSMapView *)mapView isCreatedWithBounds:(BOOL)isCreatedWithBounds; /// Removes this ground overlay from the map. @@ -33,25 +35,27 @@ @interface FLTGroundOverlaysController : NSObject /// Initializes the controller with a GMSMapView, callback handler and registrar. -- (instancetype _Nullable)initWithMapView:(GMSMapView *_Nonnull)mapView - callbackHandler:(FGMMapsCallbackApi *_Nonnull)callbackHandler - registrar:(NSObject *_Nonnull)registrar; +- (instancetype _Nullable)initWithMapView:(GMSMapView *)mapView + callbackHandler:(FGMMapsCallbackApi *)callbackHandler + registrar:(NSObject *)registrar; /// Adds ground overlays to the map. -- (void)addGroundOverlays:(NSArray *_Nonnull)groundOverlaysToAdd; +- (void)addGroundOverlays:(NSArray *)groundOverlaysToAdd; /// Updates ground overlays on the map. -- (void)changeGroundOverlays:(NSArray *_Nonnull)groundOverlaysToChange; +- (void)changeGroundOverlays:(NSArray *)groundOverlaysToChange; /// Removes ground overlays from the map. -- (void)removeGroundOverlaysWithIdentifiers:(NSArray *_Nonnull)identifiers; +- (void)removeGroundOverlaysWithIdentifiers:(NSArray *)identifiers; /// Called when a ground overlay is tapped on the map. -- (void)didTapGroundOverlayWithIdentifier:(NSString *_Nonnull)identifier; +- (void)didTapGroundOverlayWithIdentifier:(NSString *)identifier; /// Returns true if a ground overlay with the given identifier exists on the map. -- (bool)hasGroundOverlaysWithIdentifier:(NSString *_Nonnull)identifier; +- (bool)hasGroundOverlaysWithIdentifier:(NSString *)identifier; /// Returns FGMPlatformGroundOverlay for identifier. -- (nullable FGMPlatformGroundOverlay *)groundOverlayWithIdentifier:(NSString *_Nonnull)identifier; +- (nullable FGMPlatformGroundOverlay *)groundOverlayWithIdentifier:(NSString *)identifier; @end + +NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m index e5be82287c98..29d9e2e4c5a0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m @@ -3,7 +3,8 @@ // found in the LICENSE file. #import "FGMGroundOverlayController.h" -#import "FGMUtils.h" + +#import "FGMImageUtils.h" #import "FLTGoogleMapJSONConversions.h" @interface FGMGroundOverlayController () @@ -24,7 +25,7 @@ - (instancetype)initWithGroundOverlay:(GMSGroundOverlay *)groundOverlay _groundOverlay = groundOverlay; _mapView = mapView; _groundOverlay.userData = @[ identifier ]; - _isCreatedWithBounds = isCreatedWithBounds; + _createdWithBounds = isCreatedWithBounds; } return self; } @@ -77,13 +78,11 @@ - (void)updateFromPlatformGroundOverlay:(FGMPlatformGroundOverlay *)groundOverla [self setVisible:groundOverlay.visible]; [self setZIndex:(int)groundOverlay.zIndex]; [self setAnchor:CGPointMake(groundOverlay.anchor.x, groundOverlay.anchor.y)]; - UIImage *image = [FGMUtils iconFromBitmap:groundOverlay.image - registrar:registrar - screenScale:screenScale]; + UIImage *image = FGMIconFromBitmap(groundOverlay.image, registrar, screenScale); [self setIcon:image]; [self setBearing:groundOverlay.bearing]; [self setTransparency:groundOverlay.transparency]; - if (_isCreatedWithBounds) { + if ([self isCreatedWithBounds]) { [self setPositionFromBounds:[[GMSCoordinateBounds alloc] initWithCoordinate:CLLocationCoordinate2DMake( groundOverlay.bounds.northeast.latitude, @@ -104,7 +103,7 @@ @interface FLTGroundOverlaysController () /// A map from ground overlay id to the controller that manages it. @property(strong, nonatomic) NSMutableDictionary - *groundOverlayIdentifierToController; + *groundOverlayControllerByIdentifier; /// A callback api for the map interactions. @property(strong, nonatomic) FGMMapsCallbackApi *callbackHandler; @@ -126,7 +125,7 @@ - (instancetype)initWithMapView:(GMSMapView *)mapView if (self) { _callbackHandler = callbackHandler; _mapView = mapView; - _groundOverlayIdentifierToController = [[NSMutableDictionary alloc] init]; + _groundOverlayControllerByIdentifier = [[NSMutableDictionary alloc] init]; _registrar = registrar; } return self; @@ -150,18 +149,16 @@ - (void)addGroundOverlays:(NSArray *)groundOverlaysT coordinate:CLLocationCoordinate2DMake( groundOverlay.bounds.southwest.latitude, groundOverlay.bounds.southwest.longitude)] - icon:[FGMUtils iconFromBitmap:groundOverlay.image - registrar:self.registrar - screenScale:[self getScreenScale]]]; + icon:FGMIconFromBitmap(groundOverlay.image, self.registrar, + [self getScreenScale])]; } else { NSAssert(groundOverlay.zoomLevel != nil, @"If ground overlay is initialized with position, zoomLevel is required"); gmsOverlay = [GMSGroundOverlay groundOverlayWithPosition:CLLocationCoordinate2DMake(groundOverlay.position.latitude, groundOverlay.position.longitude) - icon:[FGMUtils iconFromBitmap:groundOverlay.image - registrar:self.registrar - screenScale:[self getScreenScale]] + icon:FGMIconFromBitmap(groundOverlay.image, self.registrar, + [self getScreenScale]) zoomLevel:[groundOverlay.zoomLevel doubleValue]]; } FGMGroundOverlayController *controller = @@ -173,14 +170,14 @@ - (void)addGroundOverlays:(NSArray *)groundOverlaysT [controller updateFromPlatformGroundOverlay:groundOverlay registrar:self.registrar screenScale:[self getScreenScale]]; - self.groundOverlayIdentifierToController[identifier] = controller; + self.groundOverlayControllerByIdentifier[identifier] = controller; } } - (void)changeGroundOverlays:(NSArray *)groundOverlaysToChange { for (FGMPlatformGroundOverlay *groundOverlay in groundOverlaysToChange) { NSString *identifier = groundOverlay.groundOverlayId; - FGMGroundOverlayController *controller = self.groundOverlayIdentifierToController[identifier]; + FGMGroundOverlayController *controller = self.groundOverlayControllerByIdentifier[identifier]; [controller updateFromPlatformGroundOverlay:groundOverlay registrar:self.registrar screenScale:[self getScreenScale]]; @@ -189,12 +186,12 @@ - (void)changeGroundOverlays:(NSArray *)groundOverla - (void)removeGroundOverlaysWithIdentifiers:(NSArray *)identifiers { for (NSString *identifier in identifiers) { - FGMGroundOverlayController *controller = self.groundOverlayIdentifierToController[identifier]; + FGMGroundOverlayController *controller = self.groundOverlayControllerByIdentifier[identifier]; if (!controller) { continue; } [controller removeGroundOverlay]; - [self.groundOverlayIdentifierToController removeObjectForKey:identifier]; + [self.groundOverlayControllerByIdentifier removeObjectForKey:identifier]; } } @@ -202,7 +199,7 @@ - (void)didTapGroundOverlayWithIdentifier:(NSString *)identifier { if (!identifier) { return; } - FGMGroundOverlayController *controller = self.groundOverlayIdentifierToController[identifier]; + FGMGroundOverlayController *controller = self.groundOverlayControllerByIdentifier[identifier]; if (!controller) { return; } @@ -212,10 +209,7 @@ - (void)didTapGroundOverlayWithIdentifier:(NSString *)identifier { } - (bool)hasGroundOverlaysWithIdentifier:(NSString *)identifier { - if (!identifier) { - return false; - } - return self.groundOverlayIdentifierToController[identifier] != nil; + return self.groundOverlayControllerByIdentifier[identifier] != nil; } - (CGFloat)getScreenScale { @@ -229,7 +223,7 @@ - (CGFloat)getScreenScale { } - (nullable FGMPlatformGroundOverlay *)groundOverlayWithIdentifier:(NSString *)identifier { - FGMGroundOverlayController *controller = self.groundOverlayIdentifierToController[identifier]; + FGMGroundOverlayController *controller = self.groundOverlayControllerByIdentifier[identifier]; if (!controller) { return nil; } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h new file mode 100644 index 000000000000..8aa1bcb67934 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.h @@ -0,0 +1,18 @@ +// Copyright 2013 The Flutter 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 +#import +#import "messages.g.h" + +NS_ASSUME_NONNULL_BEGIN + +/// Creates a UIImage from Pigeon bitmap. +UIImage *FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, + NSObject *registrar, CGFloat screenScale); +/// Returns a BOOL indicating whether image is considered scalable with the given scale factor from +/// size. +BOOL FGMIsScalableWithScaleFactorFromSize(CGSize originalSize, CGSize targetSize); + +NS_ASSUME_NONNULL_END diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m similarity index 84% rename from packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.m rename to packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m index 993d0a873d5e..5ad77a94e1ab 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMImageUtils.m @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "FGMUtils.h" +#import "FGMImageUtils.h" +#import "Foundation/Foundation.h" -@interface FGMUtils () +static UIImage *scaleImage(UIImage *image, double scale); +static UIImage *scaledImageWithScale(UIImage *image, CGFloat scale); +static UIImage *scaledImageWithSize(UIImage *image, CGSize size); +static UIImage *scaledImage(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale); -@end - -@implementation FGMUtils - -+ (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap - registrar:(NSObject *)registrar - screenScale:(CGFloat)screenScale { - NSAssert(screenScale > 0, @"Screen scale must be greater than 0"); +UIImage *FGMIconFromBitmap(FGMPlatformBitmap *platformBitmap, + NSObject *registrar, CGFloat screenScale) { + assert(screenScale > 0 && "Screen scale must be greater than 0"); // See comment in messages.dart for why this is so loosely typed. See also // https://github.com/flutter/flutter/issues/117819. id bitmap = platformBitmap.bitmap; @@ -40,7 +39,7 @@ + (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap // Refer to the flutter google_maps_flutter_platform_interface package for details. FGMPlatformBitmapAssetImage *bitmapAssetImage = bitmap; image = [UIImage imageNamed:[registrar lookupKeyForAsset:bitmapAssetImage.name]]; - image = [self scaleImage:image by:bitmapAssetImage.scale]; + image = scaleImage(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,10 +61,10 @@ + (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap NSNumber *width = bitmapAssetMap.width; NSNumber *height = bitmapAssetMap.height; if (width || height) { - image = [FGMUtils scaledImage:image withScale:screenScale]; - image = [FGMUtils scaledImage:image withWidth:width height:height screenScale:screenScale]; + image = scaledImageWithScale(image, screenScale); + image = scaledImage(image, width, height, screenScale); } else { - image = [FGMUtils scaledImage:image withScale:bitmapAssetMap.imagePixelRatio]; + image = scaledImageWithScale(image, bitmapAssetMap.imagePixelRatio); } } } else if ([bitmap isKindOfClass:[FGMPlatformBitmapBytesMap class]]) { @@ -80,13 +79,10 @@ + (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap if (width || height) { // Before scaling the image, image must be in screenScale. - image = [FGMUtils scaledImage:image withScale:screenScale]; - image = [FGMUtils scaledImage:image - withWidth:width - height:height - screenScale:screenScale]; + image = scaledImageWithScale(image, screenScale); + image = scaledImage(image, width, height, screenScale); } else { - image = [FGMUtils scaledImage:image withScale:bitmapBytesMap.imagePixelRatio]; + image = scaledImageWithScale(image, bitmapBytesMap.imagePixelRatio); } } else { // No scaling, load image from bytes without scale parameter. @@ -106,7 +102,7 @@ + (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap /// 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 by:(double)scale { +UIImage *scaleImage(UIImage *image, double scale) { if (fabs(scale - 1) > 1e-3) { return [UIImage imageWithCGImage:[image CGImage] scale:(image.scale * scale) @@ -123,7 +119,7 @@ + (UIImage *)scaleImage:(UIImage *)image by:(double)scale { /// @param image The UIImage to scale. /// @param scale The factor by which to scale the image. /// @return UIImage Returns the scaled UIImage. -+ (UIImage *)scaledImage:(UIImage *)image withScale:(CGFloat)scale { +UIImage *scaledImageWithScale(UIImage *image, CGFloat scale) { if (fabs(scale - image.scale) > DBL_EPSILON) { return [UIImage imageWithCGImage:[image CGImage] scale:scale @@ -140,7 +136,7 @@ + (UIImage *)scaledImage:(UIImage *)image withScale:(CGFloat)scale { /// @param image The UIImage to scale. /// @param size The target CGSize to scale the image to. /// @return UIImage Returns the scaled UIImage. -+ (UIImage *)scaledImage:(UIImage *)image withSize:(CGSize)size { +UIImage *scaledImageWithSize(UIImage *image, CGSize size) { CGFloat originalPixelWidth = image.size.width * image.scale; CGFloat originalPixelHeight = image.size.height * image.scale; @@ -159,11 +155,11 @@ + (UIImage *)scaledImage:(UIImage *)image withSize:(CGSize)size { // Check if the aspect ratios are approximately equal. CGSize originalPixelSize = CGSizeMake(originalPixelWidth, originalPixelHeight); - if ([FGMUtils isScalableWithScaleFactorFromSize:originalPixelSize toSize:size]) { + if (FGMIsScalableWithScaleFactorFromSize(originalPixelSize, size)) { // Scaled image has close to same aspect ratio, // updating image scale instead of resizing image. CGFloat factor = originalPixelWidth / size.width; - return [FGMUtils scaledImage:image withScale:(image.scale * factor)]; + return scaledImageWithScale(image, image.scale * factor); } else { // Aspect ratios differ significantly, resize the image. UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat defaultFormat]; @@ -177,7 +173,7 @@ + (UIImage *)scaledImage:(UIImage *)image withSize:(CGSize)size { }]; // Return image with proper scaling. - return [FGMUtils scaledImage:newImage withScale:image.scale]; + return scaledImageWithScale(newImage, image.scale); } } @@ -189,10 +185,7 @@ + (UIImage *)scaledImage:(UIImage *)image withSize:(CGSize)size { /// @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 - withWidth:(NSNumber *)width - height:(NSNumber *)height - screenScale:(CGFloat)screenScale { +UIImage *scaledImage(UIImage *image, NSNumber *width, NSNumber *height, CGFloat screenScale) { if (!width && !height) { return image; } @@ -212,10 +205,10 @@ + (UIImage *)scaledImage:(UIImage *)image CGSize targetSize = CGSizeMake(round(targetWidth * screenScale), round(targetHeight * screenScale)); - return [FGMUtils scaledImage:image withSize:targetSize]; + return scaledImageWithSize(image, targetSize); } -+ (BOOL)isScalableWithScaleFactorFromSize:(CGSize)originalSize toSize:(CGSize)targetSize { +BOOL FGMIsScalableWithScaleFactorFromSize(CGSize originalSize, CGSize targetSize) { // Select the scaling factor based on the longer side to have good precision. CGFloat scaleFactor = (originalSize.width > originalSize.height) ? (targetSize.width / originalSize.width) @@ -234,4 +227,3 @@ + (BOOL)isScalableWithScaleFactorFromSize:(CGSize)originalSize toSize:(CGSize)ta // if both dimensions are within the threshold. return widthWithinThreshold && heightWithinThreshold; } -@end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.h deleted file mode 100644 index e52c7e5777df..000000000000 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMUtils.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Flutter 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 -#import -#import "messages.g.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface FGMUtils : NSObject -+ (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap - registrar:(NSObject *)registrar - screenScale:(CGFloat)screenScale; -+ (BOOL)isScalableWithScaleFactorFromSize:(CGSize)originalSize toSize:(CGSize)targetSize; -@end - -NS_ASSUME_NONNULL_END 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 5f44ceb893b5..8b3a644eec6f 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 @@ -137,8 +137,8 @@ GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { longitude:groundOverlay.bounds .southWest .longitude]] - anchor:[FGMPlatformDoublePair makeWithX:groundOverlay.anchor.x - y:groundOverlay.anchor.y] + anchor:[FGMPlatformPoint makeWithX:groundOverlay.anchor.x + y:groundOverlay.anchor.y] transparency:1.0f - groundOverlay.opacity bearing:groundOverlay.bearing zIndex:groundOverlay.zIndex @@ -153,8 +153,8 @@ GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { makeWithLatitude:groundOverlay.position.latitude longitude:groundOverlay.position.longitude] bounds:nil - anchor:[FGMPlatformDoublePair makeWithX:groundOverlay.anchor.x - y:groundOverlay.anchor.y] + anchor:[FGMPlatformPoint makeWithX:groundOverlay.anchor.x + y:groundOverlay.anchor.y] transparency:1.0f - groundOverlay.opacity bearing:groundOverlay.bearing zIndex:groundOverlay.zIndex diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m index f3b0335e4ebb..a76915d7d20c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m @@ -4,8 +4,8 @@ #import "GoogleMapMarkerController.h" +#import "FGMImageUtils.h" #import "FGMMarkerUserData.h" -#import "FGMUtils.h" #import "FLTGoogleMapJSONConversions.h" @interface FLTGoogleMapMarkerController () @@ -113,9 +113,7 @@ - (void)updateFromPlatformMarker:(FGMPlatformMarker *)platformMarker [self setAlpha:platformMarker.alpha]; [self setAnchor:FGMGetCGPointForPigeonPoint(platformMarker.anchor)]; [self setDraggable:platformMarker.draggable]; - UIImage *image = [FGMUtils iconFromBitmap:platformMarker.icon - registrar:registrar - screenScale:screenScale]; + UIImage *image = FGMIconFromBitmap(platformMarker.icon, registrar, screenScale); [self setIcon:image]; [self setFlat:platformMarker.flat]; [self setConsumeTapEvents:platformMarker.consumeTapEvents]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h index 6ea64ecbb4ac..af821c5ffdfa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h @@ -5,8 +5,8 @@ #import #import #import +#import #import -#import #import #import #import diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h index 4cbedd002f0a..9d7bd9326b98 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.7.2), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -91,7 +91,6 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { @class FGMPlatformLatLng; @class FGMPlatformLatLngBounds; @class FGMPlatformCameraTargetBounds; -@class FGMPlatformDoublePair; @class FGMPlatformGroundOverlay; @class FGMPlatformMapViewCreationParams; @class FGMPlatformMapConfiguration; @@ -434,15 +433,6 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { @property(nonatomic, strong, nullable) FGMPlatformLatLngBounds *bounds; @end -/// Pair of double values, such as for an offset or size. -@interface FGMPlatformDoublePair : NSObject -/// `init` unavailable to enforce nonnull fields, see the `make` class method. -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithX:(double)x y:(double)y; -@property(nonatomic, assign) double x; -@property(nonatomic, assign) double y; -@end - /// Pigeon equivalent of the GroundOverlay class. @interface FGMPlatformGroundOverlay : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. @@ -451,7 +441,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { image:(FGMPlatformBitmap *)image position:(nullable FGMPlatformLatLng *)position bounds:(nullable FGMPlatformLatLngBounds *)bounds - anchor:(nullable FGMPlatformDoublePair *)anchor + anchor:(nullable FGMPlatformPoint *)anchor transparency:(double)transparency bearing:(double)bearing zIndex:(double)zIndex @@ -462,7 +452,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { @property(nonatomic, strong) FGMPlatformBitmap *image; @property(nonatomic, strong, nullable) FGMPlatformLatLng *position; @property(nonatomic, strong, nullable) FGMPlatformLatLngBounds *bounds; -@property(nonatomic, strong, nullable) FGMPlatformDoublePair *anchor; +@property(nonatomic, strong, nullable) FGMPlatformPoint *anchor; @property(nonatomic, assign) double transparency; @property(nonatomic, assign) double bearing; @property(nonatomic, assign) double zIndex; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m index 0ecaf0b8f82d..ad8c171a7d76 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.7.2), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.g.h" @@ -233,12 +233,6 @@ + (nullable FGMPlatformCameraTargetBounds *)nullableFromList:(NSArray *)list - (NSArray *)toList; @end -@interface FGMPlatformDoublePair () -+ (FGMPlatformDoublePair *)fromList:(NSArray *)list; -+ (nullable FGMPlatformDoublePair *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; -@end - @interface FGMPlatformGroundOverlay () + (FGMPlatformGroundOverlay *)fromList:(NSArray *)list; + (nullable FGMPlatformGroundOverlay *)nullableFromList:(NSArray *)list; @@ -1103,36 +1097,12 @@ + (nullable FGMPlatformCameraTargetBounds *)nullableFromList:(NSArray *)list } @end -@implementation FGMPlatformDoublePair -+ (instancetype)makeWithX:(double)x y:(double)y { - FGMPlatformDoublePair *pigeonResult = [[FGMPlatformDoublePair alloc] init]; - pigeonResult.x = x; - pigeonResult.y = y; - return pigeonResult; -} -+ (FGMPlatformDoublePair *)fromList:(NSArray *)list { - FGMPlatformDoublePair *pigeonResult = [[FGMPlatformDoublePair alloc] init]; - pigeonResult.x = [GetNullableObjectAtIndex(list, 0) doubleValue]; - pigeonResult.y = [GetNullableObjectAtIndex(list, 1) doubleValue]; - return pigeonResult; -} -+ (nullable FGMPlatformDoublePair *)nullableFromList:(NSArray *)list { - return (list) ? [FGMPlatformDoublePair fromList:list] : nil; -} -- (NSArray *)toList { - return @[ - @(self.x), - @(self.y), - ]; -} -@end - @implementation FGMPlatformGroundOverlay + (instancetype)makeWithGroundOverlayId:(NSString *)groundOverlayId image:(FGMPlatformBitmap *)image position:(nullable FGMPlatformLatLng *)position bounds:(nullable FGMPlatformLatLngBounds *)bounds - anchor:(nullable FGMPlatformDoublePair *)anchor + anchor:(nullable FGMPlatformPoint *)anchor transparency:(double)transparency bearing:(double)bearing zIndex:(double)zIndex @@ -1714,34 +1684,32 @@ - (nullable id)readValueOfType:(UInt8)type { case 157: return [FGMPlatformCameraTargetBounds fromList:[self readValue]]; case 158: - return [FGMPlatformDoublePair fromList:[self readValue]]; - case 159: return [FGMPlatformGroundOverlay fromList:[self readValue]]; - case 160: + case 159: return [FGMPlatformMapViewCreationParams fromList:[self readValue]]; - case 161: + case 160: return [FGMPlatformMapConfiguration fromList:[self readValue]]; - case 162: + case 161: return [FGMPlatformPoint fromList:[self readValue]]; - case 163: + case 162: return [FGMPlatformSize fromList:[self readValue]]; - case 164: + case 163: return [FGMPlatformTileLayer fromList:[self readValue]]; - case 165: + case 164: return [FGMPlatformZoomRange fromList:[self readValue]]; - case 166: + case 165: return [FGMPlatformBitmap fromList:[self readValue]]; - case 167: + case 166: return [FGMPlatformBitmapDefaultMarker fromList:[self readValue]]; - case 168: + case 167: return [FGMPlatformBitmapBytes fromList:[self readValue]]; - case 169: + case 168: return [FGMPlatformBitmapAsset fromList:[self readValue]]; - case 170: + case 169: return [FGMPlatformBitmapAssetImage fromList:[self readValue]]; - case 171: + case 170: return [FGMPlatformBitmapAssetMap fromList:[self readValue]]; - case 172: + case 171: return [FGMPlatformBitmapBytesMap fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -1844,50 +1812,47 @@ - (void)writeValue:(id)value { } else if ([value isKindOfClass:[FGMPlatformCameraTargetBounds class]]) { [self writeByte:157]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformDoublePair class]]) { - [self writeByte:158]; - [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformGroundOverlay class]]) { - [self writeByte:159]; + [self writeByte:158]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformMapViewCreationParams class]]) { - [self writeByte:160]; + [self writeByte:159]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformMapConfiguration class]]) { - [self writeByte:161]; + [self writeByte:160]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformPoint class]]) { - [self writeByte:162]; + [self writeByte:161]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformSize class]]) { - [self writeByte:163]; + [self writeByte:162]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformTileLayer class]]) { - [self writeByte:164]; + [self writeByte:163]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformZoomRange class]]) { - [self writeByte:165]; + [self writeByte:164]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmap class]]) { - [self writeByte:166]; + [self writeByte:165]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmapDefaultMarker class]]) { - [self writeByte:167]; + [self writeByte:166]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmapBytes class]]) { - [self writeByte:168]; + [self writeByte:167]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmapAsset class]]) { - [self writeByte:169]; + [self writeByte:168]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmapAssetImage class]]) { - [self writeByte:170]; + [self writeByte:169]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmapAssetMap class]]) { - [self writeByte:171]; + [self writeByte:170]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformBitmapBytesMap class]]) { - [self writeByte:172]; + [self writeByte:171]; [self writeValue:[value toList]]; } else { [super writeValue:value]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart index 66417f2e9317..475c40bcbadb 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart @@ -628,10 +628,6 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { return PlatformSize(width: size.width, height: size.height); } - static PlatformDoublePair _platformPairFromOffset(Offset offset) { - return PlatformDoublePair(x: offset.dx, y: offset.dy); - } - static PlatformCircle _platformCircleFromCircle(Circle circle) { return PlatformCircle( consumeTapEvents: circle.consumeTapEvents, @@ -681,7 +677,7 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { return PlatformGroundOverlay( groundOverlayId: groundOverlay.groundOverlayId.value, anchor: groundOverlay.anchor != null - ? _platformPairFromOffset(groundOverlay.anchor!) + ? _platformPointFromOffset(groundOverlay.anchor!) : null, image: platformBitmapFromBitmapDescriptor(groundOverlay.image), position: groundOverlay.position != null diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart index 3f488ac25719..a8745d31afc0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.7.2), do not edit directly. +// Autogenerated from Pigeon (v22.7.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -935,33 +935,6 @@ class PlatformCameraTargetBounds { } } -/// Pair of double values, such as for an offset or size. -class PlatformDoublePair { - PlatformDoublePair({ - required this.x, - required this.y, - }); - - double x; - - double y; - - Object encode() { - return [ - x, - y, - ]; - } - - static PlatformDoublePair decode(Object result) { - result as List; - return PlatformDoublePair( - x: result[0]! as double, - y: result[1]! as double, - ); - } -} - /// Pigeon equivalent of the GroundOverlay class. class PlatformGroundOverlay { PlatformGroundOverlay({ @@ -986,7 +959,7 @@ class PlatformGroundOverlay { PlatformLatLngBounds? bounds; - PlatformDoublePair? anchor; + PlatformPoint? anchor; double transparency; @@ -1023,7 +996,7 @@ class PlatformGroundOverlay { image: result[1]! as PlatformBitmap, position: result[2] as PlatformLatLng?, bounds: result[3] as PlatformLatLngBounds?, - anchor: result[4] as PlatformDoublePair?, + anchor: result[4] as PlatformPoint?, transparency: result[5]! as double, bearing: result[6]! as double, zIndex: result[7]! as double, @@ -1641,50 +1614,47 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformCameraTargetBounds) { buffer.putUint8(157); writeValue(buffer, value.encode()); - } else if (value is PlatformDoublePair) { - buffer.putUint8(158); - writeValue(buffer, value.encode()); } else if (value is PlatformGroundOverlay) { - buffer.putUint8(159); + buffer.putUint8(158); writeValue(buffer, value.encode()); } else if (value is PlatformMapViewCreationParams) { - buffer.putUint8(160); + buffer.putUint8(159); writeValue(buffer, value.encode()); } else if (value is PlatformMapConfiguration) { - buffer.putUint8(161); + buffer.putUint8(160); writeValue(buffer, value.encode()); } else if (value is PlatformPoint) { - buffer.putUint8(162); + buffer.putUint8(161); writeValue(buffer, value.encode()); } else if (value is PlatformSize) { - buffer.putUint8(163); + buffer.putUint8(162); writeValue(buffer, value.encode()); } else if (value is PlatformTileLayer) { - buffer.putUint8(164); + buffer.putUint8(163); writeValue(buffer, value.encode()); } else if (value is PlatformZoomRange) { - buffer.putUint8(165); + buffer.putUint8(164); writeValue(buffer, value.encode()); } else if (value is PlatformBitmap) { - buffer.putUint8(166); + buffer.putUint8(165); writeValue(buffer, value.encode()); } else if (value is PlatformBitmapDefaultMarker) { - buffer.putUint8(167); + buffer.putUint8(166); writeValue(buffer, value.encode()); } else if (value is PlatformBitmapBytes) { - buffer.putUint8(168); + buffer.putUint8(167); writeValue(buffer, value.encode()); } else if (value is PlatformBitmapAsset) { - buffer.putUint8(169); + buffer.putUint8(168); writeValue(buffer, value.encode()); } else if (value is PlatformBitmapAssetImage) { - buffer.putUint8(170); + buffer.putUint8(169); writeValue(buffer, value.encode()); } else if (value is PlatformBitmapAssetMap) { - buffer.putUint8(171); + buffer.putUint8(170); writeValue(buffer, value.encode()); } else if (value is PlatformBitmapBytesMap) { - buffer.putUint8(172); + buffer.putUint8(171); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -1757,34 +1727,32 @@ class _PigeonCodec extends StandardMessageCodec { case 157: return PlatformCameraTargetBounds.decode(readValue(buffer)!); case 158: - return PlatformDoublePair.decode(readValue(buffer)!); - case 159: return PlatformGroundOverlay.decode(readValue(buffer)!); - case 160: + case 159: return PlatformMapViewCreationParams.decode(readValue(buffer)!); - case 161: + case 160: return PlatformMapConfiguration.decode(readValue(buffer)!); - case 162: + case 161: return PlatformPoint.decode(readValue(buffer)!); - case 163: + case 162: return PlatformSize.decode(readValue(buffer)!); - case 164: + case 163: return PlatformTileLayer.decode(readValue(buffer)!); - case 165: + case 164: return PlatformZoomRange.decode(readValue(buffer)!); - case 166: + case 165: return PlatformBitmap.decode(readValue(buffer)!); - case 167: + case 166: return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); - case 168: + case 167: return PlatformBitmapBytes.decode(readValue(buffer)!); - case 169: + case 168: return PlatformBitmapAsset.decode(readValue(buffer)!); - case 170: + case 169: return PlatformBitmapAssetImage.decode(readValue(buffer)!); - case 171: + case 170: return PlatformBitmapAssetMap.decode(readValue(buffer)!); - case 172: + case 171: return PlatformBitmapBytesMap.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart index d754d03287e0..53ad85fa6eaf 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart @@ -357,14 +357,6 @@ class PlatformCameraTargetBounds { final PlatformLatLngBounds? bounds; } -/// Pair of double values, such as for an offset or size. -class PlatformDoublePair { - PlatformDoublePair(this.x, this.y); - - final double x; - final double y; -} - /// Pigeon equivalent of the GroundOverlay class. class PlatformGroundOverlay { PlatformGroundOverlay({ @@ -385,7 +377,7 @@ class PlatformGroundOverlay { final PlatformBitmap image; final PlatformLatLng? position; final PlatformLatLngBounds? bounds; - final PlatformDoublePair? anchor; + final PlatformPoint? anchor; final double transparency; final double bearing; final double zIndex;