diff --git a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart index 7104d01e163d..a12c7169780f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart @@ -310,43 +310,32 @@ void main() { // Object two should be changed. { expect(toChange.length, 1); - final List? encoded = toChange.first.encode() as List?; - expect(encoded?.getRange(0, 6), [ - object2new.consumeTapEvents, - object2new.fillColor.value, - object2new.strokeColor.value, - object2new.visible, - object2new.strokeWidth, - object2new.zIndex.toDouble(), - ]); - final PlatformLatLng? latLng = encoded?[6] as PlatformLatLng?; - expect(latLng?.latitude, object2new.center.latitude); - expect(latLng?.longitude, object2new.center.longitude); - expect(encoded?.getRange(7, 9), [ - object2new.radius, - object2new.circleId.value, - ]); + final PlatformCircle firstChanged = toChange.first; + expect(firstChanged.consumeTapEvents, object2new.consumeTapEvents); + expect(firstChanged.fillColor, object2new.fillColor.value); + expect(firstChanged.strokeColor, object2new.strokeColor.value); + expect(firstChanged.visible, object2new.visible); + expect(firstChanged.strokeWidth, object2new.strokeWidth); + expect(firstChanged.zIndex, object2new.zIndex.toDouble()); + expect(firstChanged.center.latitude, object2new.center.latitude); + expect(firstChanged.center.longitude, object2new.center.longitude); + expect(firstChanged.radius, object2new.radius); + expect(firstChanged.circleId, object2new.circleId.value); } // Object 3 should be added. - expect(toAdd.length, 1); { expect(toAdd.length, 1); - final List? encoded = toAdd.first.encode() as List?; - expect(encoded?.getRange(0, 6), [ - object3.consumeTapEvents, - object3.fillColor.value, - object3.strokeColor.value, - object3.visible, - object3.strokeWidth, - object3.zIndex.toDouble(), - ]); - final PlatformLatLng? latLng = encoded?[6] as PlatformLatLng?; - expect(latLng?.latitude, object3.center.latitude); - expect(latLng?.longitude, object3.center.longitude); - expect(encoded?.getRange(7, 9), [ - object3.radius, - object3.circleId.value, - ]); + final PlatformCircle firstAdded = toAdd.first; + expect(firstAdded.consumeTapEvents, object3.consumeTapEvents); + expect(firstAdded.fillColor, object3.fillColor.value); + expect(firstAdded.strokeColor, object3.strokeColor.value); + expect(firstAdded.visible, object3.visible); + expect(firstAdded.strokeWidth, object3.strokeWidth); + expect(firstAdded.zIndex, object3.zIndex.toDouble()); + expect(firstAdded.center.latitude, object3.center.latitude); + expect(firstAdded.center.longitude, object3.center.longitude); + expect(firstAdded.radius, object3.radius); + expect(firstAdded.circleId, object3.circleId.value); } }); @@ -406,72 +395,58 @@ void main() { // Object two should be changed. { expect(toChange.length, 1); - final List? encoded = toChange.first.encode() as List?; - expect(encoded?[0], object2new.alpha); - final PlatformDoublePair? offset = encoded?[1] as PlatformDoublePair?; - expect(offset?.x, object2new.anchor.dx); - expect(offset?.y, object2new.anchor.dy); - expect(encoded?.getRange(2, 5).toList(), [ - object2new.consumeTapEvents, - object2new.draggable, - object2new.flat, - ]); + final PlatformMarker firstChanged = toChange.first; + expect(firstChanged.alpha, object2new.alpha); + expect(firstChanged.anchor.x, object2new.anchor.dx); + expect(firstChanged.anchor.y, object2new.anchor.dy); + expect(firstChanged.consumeTapEvents, object2new.consumeTapEvents); + expect(firstChanged.draggable, object2new.draggable); + expect(firstChanged.flat, object2new.flat); expect( - (encoded?[5] as PlatformBitmap?)?.bitmap.runtimeType, + firstChanged.icon.bitmap.runtimeType, GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( object2new.icon) .bitmap .runtimeType); - final PlatformInfoWindow? window = encoded?[6] as PlatformInfoWindow?; - expect(window?.title, object2new.infoWindow.title); - expect(window?.snippet, object2new.infoWindow.snippet); - expect(window?.anchor.x, object2new.infoWindow.anchor.dx); - expect(window?.anchor.y, object2new.infoWindow.anchor.dy); - final PlatformLatLng? latLng = encoded?[7] as PlatformLatLng?; - expect(latLng?.latitude, object2new.position.latitude); - expect(latLng?.longitude, object2new.position.longitude); - expect(encoded?.getRange(8, 13), [ - object2new.rotation, - object2new.visible, - object2new.zIndex, - object2new.markerId.value, - object2new.clusterManagerId?.value, - ]); + expect(firstChanged.infoWindow.title, object2new.infoWindow.title); + expect(firstChanged.infoWindow.snippet, object2new.infoWindow.snippet); + expect(firstChanged.infoWindow.anchor.x, object2new.infoWindow.anchor.dx); + expect(firstChanged.infoWindow.anchor.y, object2new.infoWindow.anchor.dy); + expect(firstChanged.position.latitude, object2new.position.latitude); + expect(firstChanged.position.longitude, object2new.position.longitude); + expect(firstChanged.rotation, object2new.rotation); + expect(firstChanged.visible, object2new.visible); + expect(firstChanged.zIndex, object2new.zIndex); + expect(firstChanged.markerId, object2new.markerId.value); + expect(firstChanged.clusterManagerId, object2new.clusterManagerId?.value); } // Object 3 should be added. { expect(toAdd.length, 1); - final List? encoded = toAdd.first.encode() as List?; - expect(encoded?[0], object3.alpha); - final PlatformDoublePair? offset = encoded?[1] as PlatformDoublePair?; - expect(offset?.x, object3.anchor.dx); - expect(offset?.y, object3.anchor.dy); - expect(encoded?.getRange(2, 5).toList(), [ - object3.consumeTapEvents, - object3.draggable, - object3.flat, - ]); + final PlatformMarker firstAdded = toAdd.first; + expect(firstAdded.alpha, object3.alpha); + expect(firstAdded.anchor.x, object3.anchor.dx); + expect(firstAdded.anchor.y, object3.anchor.dy); + expect(firstAdded.consumeTapEvents, object3.consumeTapEvents); + expect(firstAdded.draggable, object3.draggable); + expect(firstAdded.flat, object3.flat); expect( - (encoded?[5] as PlatformBitmap?)?.bitmap.runtimeType, + firstAdded.icon.bitmap.runtimeType, GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( object3.icon) .bitmap .runtimeType); - final PlatformInfoWindow? window = encoded?[6] as PlatformInfoWindow?; - expect(window?.title, object3.infoWindow.title); - expect(window?.snippet, object3.infoWindow.snippet); - expect(window?.anchor.x, object3.infoWindow.anchor.dx); - expect(window?.anchor.y, object3.infoWindow.anchor.dy); - final PlatformLatLng? latLng = encoded?[7] as PlatformLatLng?; - expect(latLng?.latitude, object3.position.latitude); - expect(latLng?.longitude, object3.position.longitude); - expect(encoded?.getRange(8, 13), [ - object3.rotation, - object3.visible, - object3.zIndex, - object3.markerId.value, - object3.clusterManagerId?.value, - ]); + expect(firstAdded.infoWindow.title, object3.infoWindow.title); + expect(firstAdded.infoWindow.snippet, object3.infoWindow.snippet); + expect(firstAdded.infoWindow.anchor.x, object3.infoWindow.anchor.dx); + expect(firstAdded.infoWindow.anchor.y, object3.infoWindow.anchor.dy); + expect(firstAdded.position.latitude, object3.position.latitude); + expect(firstAdded.position.longitude, object3.position.longitude); + expect(firstAdded.rotation, object3.rotation); + expect(firstAdded.visible, object3.visible); + expect(firstAdded.zIndex, object3.zIndex); + expect(firstAdded.markerId, object3.markerId.value); + expect(firstAdded.clusterManagerId, object3.clusterManagerId?.value); } }); @@ -500,17 +475,14 @@ void main() { expect(toRemove.length, 1); expect(toRemove.first, object1.polygonId.value); void expectPolygon(PlatformPolygon actual, Polygon expected) { - final List encoded = actual.encode() as List; - expect(encoded.sublist(0, 4), [ - expected.polygonId.value, - expected.consumeTapEvents, - expected.fillColor.value, - expected.geodesic, - ]); + expect(actual.polygonId, expected.polygonId.value); + expect(actual.consumesTapEvents, expected.consumeTapEvents); + expect(actual.fillColor, expected.fillColor.value); + expect(actual.geodesic, expected.geodesic); expect(actual.points.length, expected.points.length); for (final (int i, PlatformLatLng? point) in actual.points.indexed) { - expect(point?.latitude, actual.points[i].latitude); - expect(point?.longitude, actual.points[i].longitude); + expect(point?.latitude, expected.points[i].latitude); + expect(point?.longitude, expected.points[i].longitude); } expect(actual.holes.length, expected.holes.length); for (final (int i, List? hole) in actual.holes.indexed) { @@ -520,12 +492,10 @@ void main() { expect(point?.longitude, expectedHole[j].longitude); } } - expect(encoded.sublist(6), [ - expected.visible, - expected.strokeColor.value, - expected.strokeWidth, - expected.zIndex, - ]); + expect(actual.visible, expected.visible); + expect(actual.strokeColor, expected.strokeColor.value); + expect(actual.strokeWidth, expected.strokeWidth); + expect(actual.zIndex, expected.zIndex); } // Object two should be changed. @@ -564,19 +534,15 @@ void main() { verification.captured[1] as List; final List toRemove = verification.captured[2] as List; void expectPolyline(PlatformPolyline actual, Polyline expected) { - final List encoded = actual.encode() as List; - expect(encoded.sublist(0, 5), [ - expected.polylineId.value, - expected.consumeTapEvents, - expected.color.value, - expected.geodesic, - platformJointTypeFromJointType(expected.jointType), - ]); - expect(encoded.sublist(9), [ - expected.visible, - expected.width, - expected.zIndex, - ]); + expect(actual.polylineId, expected.polylineId.value); + expect(actual.consumesTapEvents, expected.consumeTapEvents); + expect(actual.color, expected.color.value); + expect(actual.geodesic, expected.geodesic); + expect( + actual.jointType, platformJointTypeFromJointType(expected.jointType)); + expect(actual.visible, expected.visible); + expect(actual.width, expected.width); + expect(actual.zIndex, expected.zIndex); expect(actual.points.length, expected.points.length); for (final (int i, PlatformLatLng? point) in actual.points.indexed) { expect(point?.latitude, actual.points[i].latitude); @@ -639,15 +605,13 @@ void main() { final List toChange = verification.captured[1] as List; final List toRemove = verification.captured[2] as List; - void expectTileOverlay(PlatformTileOverlay? actual, TileOverlay expected) { - expect(actual?.encode(), [ - expected.tileOverlayId.value, - expected.fadeIn, - expected.transparency, - expected.zIndex, - expected.visible, - expected.tileSize, - ]); + void expectTileOverlay(PlatformTileOverlay actual, TileOverlay expected) { + expect(actual.tileOverlayId, expected.tileOverlayId.value); + expect(actual.fadeIn, expected.fadeIn); + expect(actual.transparency, expected.transparency); + expect(actual.zIndex, expected.zIndex); + expect(actual.visible, expected.visible); + expect(actual.tileSize, expected.tileSize); } // Object one should be removed. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 5f962bb978d6..a42fa3d3076e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.13.2 + +* Updates most objects passed from Dart to native to use typed data. + ## 2.13.1 * Updates Pigeon for non-nullable collection type support. 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 c3d6a363e0c4..811f09d49b45 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 @@ -23,16 +23,18 @@ - (void)testExtractIconFromDataAssetAuto { OCMStub([mockRegistrar lookupKeyForAsset:@"fakeImageNameKey"]).andReturn(@"fakeAssetKey"); OCMStub(ClassMethod([mockImageClass imageNamed:@"fakeAssetKey"])).andReturn(testImage); - NSDictionary *assetData = - @{@"assetName" : @"fakeImageNameKey", @"bitmapScaling" : @"auto", @"imagePixelRatio" : @1}; - - NSArray *iconData = @[ @"asset", assetData ]; + FGMPlatformBitmapAssetMap *bitmap = + [FGMPlatformBitmapAssetMap makeWithAssetName:@"fakeImageNameKey" + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:1 + width:nil + height:nil]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); XCTAssertEqual(resultImage.size.width, 1.0); @@ -49,16 +51,18 @@ - (void)testExtractIconFromDataAssetAutoWithScale { OCMStub([mockRegistrar lookupKeyForAsset:@"fakeImageNameKey"]).andReturn(@"fakeAssetKey"); OCMStub(ClassMethod([mockImageClass imageNamed:@"fakeAssetKey"])).andReturn(testImage); - NSDictionary *assetData = - @{@"assetName" : @"fakeImageNameKey", @"bitmapScaling" : @"auto", @"imagePixelRatio" : @10}; - - NSArray *iconData = @[ @"asset", assetData ]; + FGMPlatformBitmapAssetMap *bitmap = + [FGMPlatformBitmapAssetMap makeWithAssetName:@"fakeImageNameKey" + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:10 + width:nil + height:nil]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 10); @@ -77,29 +81,29 @@ - (void)testExtractIconFromDataAssetAutoAndSizeWithSameAspectRatio { OCMStub([mockRegistrar lookupKeyForAsset:@"fakeImageNameKey"]).andReturn(@"fakeAssetKey"); OCMStub(ClassMethod([mockImageClass imageNamed:@"fakeAssetKey"])).andReturn(testImage); - NSDictionary *assetData = @{ - @"assetName" : @"fakeImageNameKey", - @"bitmapScaling" : @"auto", - @"imagePixelRatio" : @1, - @"width" : @15.0 - }; // Target height + const CGFloat width = 15.0; + FGMPlatformBitmapAssetMap *bitmap = + [FGMPlatformBitmapAssetMap makeWithAssetName:@"fakeImageNameKey" + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:1 + width:@(width) + height:nil]; - NSArray *iconData = @[ @"asset", assetData ]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(testImage.scale, 1.0); // As image has same aspect ratio as the original image, // only image scale has been changed to match the target size. - CGFloat targetScale = testImage.scale * (testImage.size.width / 15.0); + CGFloat targetScale = testImage.scale * (testImage.size.width / width); const CGFloat accuracy = 0.001; XCTAssertEqualWithAccuracy(resultImage.scale, targetScale, accuracy); - XCTAssertEqual(resultImage.size.width, 15.0); - XCTAssertEqual(resultImage.size.height, 15.0); + XCTAssertEqual(resultImage.size.width, width); + XCTAssertEqual(resultImage.size.height, width); } - (void)testExtractIconFromDataAssetAutoAndSizeWithDifferentAspectRatio { @@ -112,25 +116,24 @@ - (void)testExtractIconFromDataAssetAutoAndSizeWithDifferentAspectRatio { OCMStub([mockRegistrar lookupKeyForAsset:@"fakeImageNameKey"]).andReturn(@"fakeAssetKey"); OCMStub(ClassMethod([mockImageClass imageNamed:@"fakeAssetKey"])).andReturn(testImage); - NSDictionary *assetData = @{ - @"assetName" : @"fakeImageNameKey", - @"bitmapScaling" : @"auto", - @"imagePixelRatio" : @1, - @"width" : @15.0, - @"height" : @45.0 - }; - - NSArray *iconData = @[ @"asset", assetData ]; + const CGFloat width = 15.0; + const CGFloat height = 45.0; + FGMPlatformBitmapAssetMap *bitmap = + [FGMPlatformBitmapAssetMap makeWithAssetName:@"fakeImageNameKey" + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:1 + width:@(width) + height:@(height)]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, screenScale); - XCTAssertEqual(resultImage.size.width, 15.0); - XCTAssertEqual(resultImage.size.height, 45.0); + XCTAssertEqual(resultImage.size.width, width); + XCTAssertEqual(resultImage.size.height, height); } - (void)testExtractIconFromDataAssetNoScaling { @@ -143,16 +146,18 @@ - (void)testExtractIconFromDataAssetNoScaling { OCMStub([mockRegistrar lookupKeyForAsset:@"fakeImageNameKey"]).andReturn(@"fakeAssetKey"); OCMStub(ClassMethod([mockImageClass imageNamed:@"fakeAssetKey"])).andReturn(testImage); - NSDictionary *assetData = - @{@"assetName" : @"fakeImageNameKey", @"bitmapScaling" : @"none", @"imagePixelRatio" : @10}; - - NSArray *iconData = @[ @"asset", assetData ]; + FGMPlatformBitmapAssetMap *bitmap = + [FGMPlatformBitmapAssetMap makeWithAssetName:@"fakeImageNameKey" + bitmapScaling:FGMPlatformMapBitmapScalingNone + imagePixelRatio:1 + width:nil + height:nil]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); @@ -169,16 +174,18 @@ - (void)testExtractIconFromDataBytesAuto { XCTAssertNotNil(pngData); FlutterStandardTypedData *typedData = [FlutterStandardTypedData typedDataWithBytes:pngData]; + FGMPlatformBitmapBytesMap *bitmap = + [FGMPlatformBitmapBytesMap makeWithByteData:typedData + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:1 + width:nil + height:nil]; - NSDictionary *bytesData = - @{@"byteData" : typedData, @"bitmapScaling" : @"auto", @"imagePixelRatio" : @1}; - - NSArray *iconData = @[ @"bytes", bytesData ]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); @@ -195,17 +202,18 @@ - (void)testExtractIconFromDataBytesAutoWithScaling { XCTAssertNotNil(pngData); FlutterStandardTypedData *typedData = [FlutterStandardTypedData typedDataWithBytes:pngData]; - - NSDictionary *bytesData = - @{@"byteData" : typedData, @"bitmapScaling" : @"auto", @"imagePixelRatio" : @10}; - - NSArray *iconData = @[ @"bytes", bytesData ]; + FGMPlatformBitmapBytesMap *bitmap = + [FGMPlatformBitmapBytesMap makeWithByteData:typedData + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:10 + width:nil + height:nil]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 10); XCTAssertEqual(resultImage.size.width, 0.1); @@ -220,34 +228,32 @@ - (void)testExtractIconFromDataBytesAutoAndSizeWithSameAspectRatio { NSData *pngData = UIImagePNGRepresentation(testImage); XCTAssertNotNil(pngData); + const CGFloat width = 15.0; + const CGFloat height = 15.0; FlutterStandardTypedData *typedData = [FlutterStandardTypedData typedDataWithBytes:pngData]; - - NSDictionary *bytesData = @{ - @"byteData" : typedData, - @"bitmapScaling" : @"auto", - @"imagePixelRatio" : @1, - @"width" : @15.0, - @"height" : @15.0 - }; - - NSArray *iconData = @[ @"bytes", bytesData ]; + FGMPlatformBitmapBytesMap *bitmap = + [FGMPlatformBitmapBytesMap makeWithByteData:typedData + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:1 + width:@(width) + height:@(height)]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(testImage.scale, 1.0); // As image has same aspect ratio as the original image, // only image scale has been changed to match the target size. - CGFloat targetScale = testImage.scale * (testImage.size.width / 15.0); + CGFloat targetScale = testImage.scale * (testImage.size.width / width); const CGFloat accuracy = 0.001; XCTAssertEqualWithAccuracy(resultImage.scale, targetScale, accuracy); - XCTAssertEqual(resultImage.size.width, 15.0); - XCTAssertEqual(resultImage.size.height, 15.0); + XCTAssertEqual(resultImage.size.width, width); + XCTAssertEqual(resultImage.size.height, height); } - (void)testExtractIconFromDataBytesAutoAndSizeWithDifferentAspectRatio { @@ -258,26 +264,25 @@ - (void)testExtractIconFromDataBytesAutoAndSizeWithDifferentAspectRatio { NSData *pngData = UIImagePNGRepresentation(testImage); XCTAssertNotNil(pngData); + const CGFloat width = 15.0; + const CGFloat height = 45.0; FlutterStandardTypedData *typedData = [FlutterStandardTypedData typedDataWithBytes:pngData]; + FGMPlatformBitmapBytesMap *bitmap = + [FGMPlatformBitmapBytesMap makeWithByteData:typedData + bitmapScaling:FGMPlatformMapBitmapScalingAuto + imagePixelRatio:1 + width:@(width) + height:@(height)]; - NSDictionary *bytesData = @{ - @"byteData" : typedData, - @"bitmapScaling" : @"auto", - @"imagePixelRatio" : @1, - @"width" : @15.0, - @"height" : @45.0 - }; - - NSArray *iconData = @[ @"bytes", bytesData ]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, screenScale); - XCTAssertEqual(resultImage.size.width, 15.0); - XCTAssertEqual(resultImage.size.height, 45.0); + XCTAssertEqual(resultImage.size.width, width); + XCTAssertEqual(resultImage.size.height, height); } - (void)testExtractIconFromDataBytesNoScaling { @@ -289,16 +294,18 @@ - (void)testExtractIconFromDataBytesNoScaling { XCTAssertNotNil(pngData); FlutterStandardTypedData *typedData = [FlutterStandardTypedData typedDataWithBytes:pngData]; + FGMPlatformBitmapBytesMap *bitmap = + [FGMPlatformBitmapBytesMap makeWithByteData:typedData + bitmapScaling:FGMPlatformMapBitmapScalingNone + imagePixelRatio:1 + width:nil + height:nil]; - NSDictionary *bytesData = - @{@"byteData" : typedData, @"bitmapScaling" : @"none", @"imagePixelRatio" : @1}; - - NSArray *iconData = @[ @"bytes", bytesData ]; CGFloat screenScale = 3.0; - UIImage *resultImage = [instance extractIconFromData:iconData - registrar:mockRegistrar - screenScale:screenScale]; + UIImage *resultImage = [instance iconFromBitmap:[FGMPlatformBitmap makeWithBitmap:bitmap] + registrar:mockRegistrar + screenScale:screenScale]; XCTAssertNotNil(resultImage); XCTAssertEqual(resultImage.scale, 1.0); XCTAssertEqual(resultImage.size.width, 1.0); @@ -362,7 +369,7 @@ - (UIImage *)createOnePixelImage { UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size format:format]; UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull context) { - [[UIColor whiteColor] setFill]; + [UIColor.whiteColor setFill]; [context fillRect:CGRectMake(0, 0, size.width, size.height)]; }]; return image; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FGMClusterManagersControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FGMClusterManagersControllerTests.m index 6fdcccf468dd..8d435eb4941c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FGMClusterManagersControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FGMClusterManagersControllerTests.m @@ -52,16 +52,39 @@ - (void)testClustering { NSString *markerId1 = @"m1"; NSString *markerId2 = @"m2"; - FGMPlatformMarker *marker1 = [FGMPlatformMarker makeWithJson:@{ - @"markerId" : markerId1, - @"position" : @[ @0, @0 ], - @"clusterManagerId" : clusterManagerId - }]; - FGMPlatformMarker *marker2 = [FGMPlatformMarker makeWithJson:@{ - @"markerId" : markerId2, - @"position" : @[ @0, @0 ], - @"clusterManagerId" : clusterManagerId - }]; + FGMPlatformPoint *zeroPoint = [FGMPlatformPoint makeWithX:0 y:0]; + FGMPlatformLatLng *zeroLatLng = [FGMPlatformLatLng makeWithLatitude:0 longitude:0]; + FGMPlatformBitmap *bitmap = + [FGMPlatformBitmap makeWithBitmap:[FGMPlatformBitmapDefaultMarker makeWithHue:0]]; + FGMPlatformInfoWindow *infoWindow = [FGMPlatformInfoWindow makeWithTitle:@"Info" + snippet:NULL + anchor:zeroPoint]; + FGMPlatformMarker *marker1 = [FGMPlatformMarker makeWithAlpha:1 + anchor:zeroPoint + consumeTapEvents:NO + draggable:NO + flat:NO + icon:bitmap + infoWindow:infoWindow + position:zeroLatLng + rotation:0 + visible:YES + zIndex:1 + markerId:markerId1 + clusterManagerId:clusterManagerId]; + FGMPlatformMarker *marker2 = [FGMPlatformMarker makeWithAlpha:1 + anchor:zeroPoint + consumeTapEvents:NO + draggable:NO + flat:NO + icon:bitmap + infoWindow:infoWindow + position:zeroLatLng + rotation:0 + visible:YES + zIndex:1 + markerId:markerId2 + clusterManagerId:clusterManagerId]; [markersController addMarkers:@[ marker1, marker2 ]]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m index c66698c6834e..cb7c63a72768 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m @@ -72,8 +72,11 @@ - (void)testColorFromRGBA { } - (void)testPointsFromLatLongs { - NSArray *latlongs = @[ @[ @1, @2 ], @[ @(3), @(4) ] ]; - NSArray *locations = [FLTGoogleMapJSONConversions pointsFromLatLongs:latlongs]; + NSArray *latlongs = @[ + [FGMPlatformLatLng makeWithLatitude:1 longitude:2], [FGMPlatformLatLng makeWithLatitude:3 + longitude:4] + ]; + NSArray *locations = FGMGetPointsForPigeonLatLngs(latlongs); XCTAssertEqual(locations.count, 2); XCTAssertEqual(locations[0].coordinate.latitude, 1); XCTAssertEqual(locations[0].coordinate.longitude, 2); @@ -82,10 +85,17 @@ - (void)testPointsFromLatLongs { } - (void)testHolesFromPointsArray { - NSArray *pointsArray = - @[ @[ @[ @1, @2 ], @[ @(3), @(4) ] ], @[ @[ @(5), @(6) ], @[ @(7), @(8) ] ] ]; - NSArray *> *holes = - [FLTGoogleMapJSONConversions holesFromPointsArray:pointsArray]; + NSArray *> *pointsArray = @[ + @[ + [FGMPlatformLatLng makeWithLatitude:1 longitude:2], [FGMPlatformLatLng makeWithLatitude:3 + longitude:4] + ], + @[ + [FGMPlatformLatLng makeWithLatitude:5 longitude:6], [FGMPlatformLatLng makeWithLatitude:7 + longitude:8] + ] + ]; + NSArray *> *holes = FGMGetHolesForPigeonLatLngArrays(pointsArray); XCTAssertEqual(holes.count, 2); XCTAssertEqual(holes[0][0].coordinate.latitude, 1); XCTAssertEqual(holes[0][0].coordinate.longitude, 2); @@ -134,23 +144,6 @@ - (void)testPigeonLatLngBoundsForCoordinateBounds { DBL_EPSILON); } -- (void)testCameraPostionFromDictionary { - XCTAssertNil([FLTGoogleMapJSONConversions cameraPostionFromDictionary:nil]); - - NSDictionary *channelValue = - @{@"target" : @[ @1, @2 ], @"zoom" : @3, @"bearing" : @4, @"tilt" : @5}; - - GMSCameraPosition *cameraPosition = - [FLTGoogleMapJSONConversions cameraPostionFromDictionary:channelValue]; - - const CGFloat accuracy = 0.001; - XCTAssertEqualWithAccuracy(cameraPosition.target.latitude, 1, accuracy); - XCTAssertEqualWithAccuracy(cameraPosition.target.longitude, 2, accuracy); - XCTAssertEqualWithAccuracy(cameraPosition.zoom, 3, accuracy); - XCTAssertEqualWithAccuracy(cameraPosition.bearing, 4, accuracy); - XCTAssertEqualWithAccuracy(cameraPosition.viewingAngle, 5, accuracy); -} - - (void)testGetCameraPostionForPigeonCameraPosition { FGMPlatformCameraPosition *pigeonCameraPosition = [FGMPlatformCameraPosition makeWithBearing:1.0 @@ -180,11 +173,11 @@ - (void)testCGPointForPigeonPoint { } - (void)testCoordinateBoundsFromLatLongs { - NSArray *latlong1 = @[ @1, @2 ]; - NSArray *latlong2 = @[ @(3), @(4) ]; + FGMPlatformLatLngBounds *pigeonBounds = [FGMPlatformLatLngBounds + makeWithNortheast:[FGMPlatformLatLng makeWithLatitude:3 longitude:4] + southwest:[FGMPlatformLatLng makeWithLatitude:1 longitude:2]]; - GMSCoordinateBounds *bounds = - [FLTGoogleMapJSONConversions coordinateBoundsFromLatLongs:@[ latlong1, latlong2 ]]; + GMSCoordinateBounds *bounds = FGMGetCoordinateBoundsForPigeonLatLngBounds(pigeonBounds); const CGFloat accuracy = 0.001; XCTAssertEqualWithAccuracy(bounds.southWest.latitude, 1, accuracy); @@ -201,14 +194,20 @@ - (void)testMapViewTypeFromPigeonType { XCTAssertEqual(kGMSTypeNone, FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapTypeNone)); } -- (void)testCameraUpdateFromArrayNewCameraPosition { - NSArray *channelValue = @[ - @"newCameraPosition", @{@"target" : @[ @1, @2 ], @"zoom" : @3, @"bearing" : @4, @"tilt" : @5} - ]; +- (void)testCameraUpdateFromNewCameraPosition { id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue]; + FGMPlatformCameraUpdateNewCameraPosition *newPositionUpdate = + [FGMPlatformCameraUpdateNewCameraPosition + makeWithCameraPosition:[FGMPlatformCameraPosition + makeWithBearing:4 + target:[FGMPlatformLatLng makeWithLatitude:1 + longitude:2] + tilt:5 + zoom:3]]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:newPositionUpdate]); [[classMockCameraUpdate expect] - setCamera:[FLTGoogleMapJSONConversions cameraPostionFromDictionary:channelValue[1]]]; + setCamera:FGMGetCameraPositionForPigeonCameraPosition(newPositionUpdate.cameraPosition)]; [classMockCameraUpdate stopMocking]; } @@ -226,10 +225,14 @@ - (void)testCameraUpdateFromArrayNewCameraPosition { // verified. // // The code in below test uses the 2nd approach. -- (void)skip_testCameraUpdateFromArrayNewLatLong { - NSArray *channelValue = @[ @"newLatLng", @[ @1, @2 ] ]; +- (void)skip_testCameraUpdateFromNewLatLong { + const CGFloat lat = 1; + const CGFloat lng = 2; + FGMPlatformCameraUpdateNewLatLng *platformUpdate = [FGMPlatformCameraUpdateNewLatLng + makeWithLatLng:[FGMPlatformLatLng makeWithLatitude:lat longitude:lng]]; - GMSCameraUpdate *update = [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue]; + GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init]; options.frame = CGRectZero; @@ -237,104 +240,150 @@ - (void)skip_testCameraUpdateFromArrayNewLatLong { GMSMapView *mapView = [[GMSMapView alloc] initWithOptions:options]; [mapView moveCamera:update]; const CGFloat accuracy = 0.001; - XCTAssertEqualWithAccuracy(mapView.camera.target.latitude, 1, + XCTAssertEqualWithAccuracy(mapView.camera.target.latitude, lat, accuracy); // mapView.camera.target.latitude is still 5. - XCTAssertEqualWithAccuracy(mapView.camera.target.longitude, 2, + XCTAssertEqualWithAccuracy(mapView.camera.target.longitude, lng, accuracy); // mapView.camera.target.longitude is still 6. } -- (void)testCameraUpdateFromArrayNewLatLngBounds { - NSArray *latlong1 = @[ @1, @2 ]; - NSArray *latlong2 = @[ @(3), @(4) ]; - GMSCoordinateBounds *bounds = - [FLTGoogleMapJSONConversions coordinateBoundsFromLatLongs:@[ latlong1, latlong2 ]]; +- (void)testCameraUpdateFromNewLatLngBounds { + FGMPlatformLatLngBounds *pigeonBounds = [FGMPlatformLatLngBounds + makeWithNortheast:[FGMPlatformLatLng makeWithLatitude:1 longitude:2] + southwest:[FGMPlatformLatLng makeWithLatitude:3 longitude:4]]; + GMSCoordinateBounds *bounds = FGMGetCoordinateBoundsForPigeonLatLngBounds(pigeonBounds); - NSArray *channelValue = @[ @"newLatLngBounds", @[ latlong1, latlong2 ], @20 ]; + const CGFloat padding = 20; + FGMPlatformCameraUpdateNewLatLngBounds *platformUpdate = [FGMPlatformCameraUpdateNewLatLngBounds + makeWithBounds:FGMGetPigeonLatLngBoundsForCoordinateBounds(bounds) + padding:padding]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); - [[classMockCameraUpdate expect] fitBounds:bounds withPadding:20]; + [[classMockCameraUpdate expect] fitBounds:bounds withPadding:padding]; [classMockCameraUpdate stopMocking]; } -- (void)testCameraUpdateFromArrayNewLatLngZoom { - NSArray *channelValue = @[ @"newLatLngZoom", @[ @1, @2 ], @3 ]; +- (void)testCameraUpdateFromNewLatLngZoom { + const CGFloat lat = 1; + const CGFloat lng = 2; + const CGFloat zoom = 3; + FGMPlatformCameraUpdateNewLatLngZoom *platformUpdate = [FGMPlatformCameraUpdateNewLatLngZoom + makeWithLatLng:[FGMPlatformLatLng makeWithLatitude:lat longitude:lng] + zoom:zoom]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); - [[classMockCameraUpdate expect] setTarget:CLLocationCoordinate2DMake(1, 2) zoom:3]; + [[classMockCameraUpdate expect] setTarget:CLLocationCoordinate2DMake(lat, lng) zoom:zoom]; [classMockCameraUpdate stopMocking]; } -- (void)testCameraUpdateFromArrayScrollBy { - NSArray *channelValue = @[ @"scrollBy", @1, @2 ]; +- (void)testCameraUpdateFromScrollBy { + const CGFloat x = 1; + const CGFloat y = 2; + FGMPlatformCameraUpdateScrollBy *platformUpdate = [FGMPlatformCameraUpdateScrollBy makeWithDx:x + dy:y]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValue]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); - [[classMockCameraUpdate expect] scrollByX:1 Y:2]; + [[classMockCameraUpdate expect] scrollByX:x Y:y]; [classMockCameraUpdate stopMocking]; } -- (void)testCameraUpdateFromArrayZoomBy { - NSArray *channelValueNoPoint = @[ @"zoomBy", @1 ]; +- (void)testCameraUpdateFromZoomBy { + const CGFloat zoom = 1; + FGMPlatformCameraUpdateZoomBy *platformUpdateNoPoint = + [FGMPlatformCameraUpdateZoomBy makeWithAmount:zoom focus:nil]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdateNoPoint]); - [[classMockCameraUpdate expect] zoomBy:1]; + [[classMockCameraUpdate expect] zoomBy:zoom]; - NSArray *channelValueWithPoint = @[ @"zoomBy", @1, @[ @2, @3 ] ]; + const CGFloat x = 2; + const CGFloat y = 3; + FGMPlatformCameraUpdateZoomBy *platformUpdate = + [FGMPlatformCameraUpdateZoomBy makeWithAmount:zoom focus:[FGMPlatformPoint makeWithX:x y:y]]; - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueWithPoint]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); - [[classMockCameraUpdate expect] zoomBy:1 atPoint:CGPointMake(2, 3)]; + [[classMockCameraUpdate expect] zoomBy:zoom atPoint:CGPointMake(x, y)]; [classMockCameraUpdate stopMocking]; } -- (void)testCameraUpdateFromArrayZoomIn { - NSArray *channelValueNoPoint = @[ @"zoomIn" ]; +- (void)testCameraUpdateFromZoomIn { + FGMPlatformCameraUpdateZoom *platformUpdate = [FGMPlatformCameraUpdateZoom makeWithOut:NO]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); [[classMockCameraUpdate expect] zoomIn]; [classMockCameraUpdate stopMocking]; } -- (void)testCameraUpdateFromArrayZoomOut { - NSArray *channelValueNoPoint = @[ @"zoomOut" ]; +- (void)testCameraUpdateFromZoomOut { + FGMPlatformCameraUpdateZoom *platformUpdate = [FGMPlatformCameraUpdateZoom makeWithOut:YES]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); [[classMockCameraUpdate expect] zoomOut]; [classMockCameraUpdate stopMocking]; } -- (void)testCameraUpdateFromArrayZoomTo { - NSArray *channelValueNoPoint = @[ @"zoomTo", @1 ]; +- (void)testCameraUpdateFromZoomTo { + const CGFloat zoom = 1; + FGMPlatformCameraUpdateZoomTo *platformUpdate = [FGMPlatformCameraUpdateZoomTo makeWithZoom:zoom]; id classMockCameraUpdate = OCMClassMock([GMSCameraUpdate class]); - [FLTGoogleMapJSONConversions cameraUpdateFromArray:channelValueNoPoint]; + FGMGetCameraUpdateForPigeonCameraUpdate( + [FGMPlatformCameraUpdate makeWithCameraUpdate:platformUpdate]); - [[classMockCameraUpdate expect] zoomTo:1]; + [[classMockCameraUpdate expect] zoomTo:zoom]; [classMockCameraUpdate stopMocking]; } +- (void)testStrokeStylesFromPatterns { + NSArray *patterns = @[ + [FGMPlatformPatternItem makeWithType:FGMPlatformPatternItemTypeGap length:@(1)], + [FGMPlatformPatternItem makeWithType:FGMPlatformPatternItemTypeDash length:@(1)] + ]; + UIColor *strokeColor = UIColor.redColor; + + NSArray *patternStrokeStyle = + FGMGetStrokeStylesFromPatterns(patterns, strokeColor); + + XCTAssertEqual(patternStrokeStyle.count, 2); + + // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing + // the length of this output array. +} + - (void)testLengthsFromPatterns { - NSArray *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @6.4 ] ]; + const CGFloat gapLength = 10; + const CGFloat dashLength = 6.4; + NSArray *patterns = @[ + [FGMPlatformPatternItem makeWithType:FGMPlatformPatternItemTypeGap length:@(gapLength)], + [FGMPlatformPatternItem makeWithType:FGMPlatformPatternItemTypeDash length:@(dashLength)] + ]; - NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; + NSArray *spanLengths = FGMGetSpanLengthsFromPatterns(patterns); - XCTAssertEqual([spanLengths count], 2); + XCTAssertEqual(spanLengths.count, 2); NSNumber *firstSpanLength = spanLengths[0]; NSNumber *secondSpanLength = spanLengths[1]; - XCTAssertEqual(firstSpanLength.doubleValue, 10); - XCTAssertEqual(secondSpanLength.doubleValue, 6.4); + XCTAssertEqual(firstSpanLength.doubleValue, gapLength); + XCTAssertEqual(secondSpanLength.doubleValue, dashLength); } - (void)testWeightedLatLngFromArray { diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 0ce0f53e00c4..edb0ed03096d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -9,6 +9,7 @@ #import #import +#import #import "PartiallyMockedMapView.h" @interface GoogleMapsPolylinesControllerTests : XCTestCase @@ -20,13 +21,22 @@ @implementation GoogleMapsPolylinesControllerTests /// /// @return An object of FLTGoogleMapPolylineController - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { - NSDictionary *polyline = @{ - @"points" : @[ - @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], - @[ @(53.4153), @(-4.0829) ] - ], - @"polylineId" : @"polyline_id_0", - }; + FGMPlatformPolyline *polyline = [FGMPlatformPolyline + makeWithPolylineId:@"polyline_id_0" + consumesTapEvents:NO + color:0 + geodesic:NO + jointType:FGMPlatformJointTypeRound + patterns:@[] + points:@[ + [FGMPlatformLatLng makeWithLatitude:52.4816 longitude:-3.1791], + [FGMPlatformLatLng makeWithLatitude:54.043 longitude:-2.9925], + [FGMPlatformLatLng makeWithLatitude:54.1396 longitude:-4.2739], + [FGMPlatformLatLng makeWithLatitude:53.4153 longitude:-4.0829], + ] + visible:NO + width:1 + zIndex:0]; CGRect frame = CGRectMake(0, 0, 100, 100); GMSCameraPosition *camera = [[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]; @@ -37,12 +47,11 @@ - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] initWithOptions:mapViewOptions]; - GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; - NSString *identifier = polyline[@"polylineId"]; + GMSMutablePath *path = FGMGetPathFromPoints(FGMGetPointsForPigeonLatLngs(polyline.points)); FLTGoogleMapPolylineController *polylineControllerWithMockedMap = [[FLTGoogleMapPolylineController alloc] initWithPath:path - identifier:identifier + identifier:polyline.polylineId mapView:mapView]; return polylineControllerWithMockedMap; @@ -50,7 +59,7 @@ - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { - (void)testSetPatterns { NSArray *styles = @[ - [GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]] + [GMSStrokeStyle solidColor:UIColor.clearColor], [GMSStrokeStyle solidColor:UIColor.redColor] ]; NSArray *lengths = @[ @10, @10 ]; @@ -65,17 +74,4 @@ - (void)testSetPatterns { XCTAssertNotNil(polylineController.polyline.spans); } -- (void)testStrokeStylesFromPatterns { - NSArray *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; - UIColor *strokeColor = [UIColor redColor]; - - NSArray *patternStrokeStyle = - [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; - - XCTAssertEqual([patternStrokeStyle count], 2); - - // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing - // the length of this output array. -} - @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index ba68ca7a5b5b..2d853e9bfe98 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -42,6 +42,15 @@ extern FGMPlatformCameraPosition *FGMGetPigeonCameraPositionForPosition( extern GMSCameraPosition *FGMGetCameraPositionForPigeonCameraPosition( FGMPlatformCameraPosition *position); +/// Creates a CLLocation array from its Pigeon equivalent. +extern NSArray *FGMGetPointsForPigeonLatLngs(NSArray *points); + +/// Creates a CLLocation arary array, representing a set of holes, from its Pigeon equivalent. +extern NSArray *> *FGMGetHolesForPigeonLatLngArrays( + NSArray *> *points); + +extern GMSMutablePath *FGMGetPathFromPoints(NSArray *points); + /// Creates a GMSMapViewType from its Pigeon representation. extern GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type); @@ -49,6 +58,21 @@ extern GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) extern FGMPlatformCluster *FGMGetPigeonCluster(GMUStaticCluster *cluster, NSString *clusterManagerIdentifier); +/// Creates a GMSCameraUpdate from its Pigeon equivalent. +extern GMSCameraUpdate *_Nullable FGMGetCameraUpdateForPigeonCameraUpdate( + FGMPlatformCameraUpdate *update); + +/// Creates a UIColor from its RGBA components, expressed as an integer. +extern UIColor *FGMGetColorForRGBA(NSInteger rgba); + +/// Creates an array of GMSStrokeStyles using the given patterns and stroke color. +extern NSArray *FGMGetStrokeStylesFromPatterns( + NSArray *patterns, UIColor *strokeColor); + +/// Creates an array of span lengths using the given patterns. +extern NSArray *FGMGetSpanLengthsFromPatterns( + NSArray *patterns); + @interface FLTGoogleMapJSONConversions : NSObject extern NSString *const kHeatmapsToAddKey; @@ -68,11 +92,6 @@ extern NSString *const kHeatmapGradientColorMapSizeKey; + (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location; + (UIColor *)colorFromRGBA:(NSNumber *)data; + (NSNumber *)RGBAFromColor:(UIColor *)color; -+ (NSArray *)pointsFromLatLongs:(NSArray *)data; -+ (NSArray *> *)holesFromPointsArray:(NSArray *)data; -+ (nullable GMSCameraPosition *)cameraPostionFromDictionary:(nullable NSDictionary *)channelValue; -+ (GMSCoordinateBounds *)coordinateBoundsFromLatLongs:(NSArray *)latlongs; -+ (nullable GMSCameraUpdate *)cameraUpdateFromArray:(NSArray *)channelValue; + (nullable GMUWeightedLatLng *)weightedLatLngFromArray:(NSArray *)data; + (NSArray *)arrayFromWeightedLatLng:(GMUWeightedLatLng *)weightedLatLng; + (NSArray *)weightedDataFromArray:(NSArray *> *)data; @@ -80,21 +99,6 @@ extern NSString *const kHeatmapGradientColorMapSizeKey; + (GMUGradient *)gradientFromDictionary:(NSDictionary *)data; + (NSDictionary *)dictionaryFromGradient:(GMUGradient *)gradient; -/// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. -/// -/// @param patterns An array of patterns for each stroke in the polyline. -/// @param strokeColor An array of color for each stroke in the polyline. -/// @return An array of GMSStrokeStyle. -+ (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns - strokeColor:(UIColor *)strokeColor; - -/// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. -/// Extracts the lengths of each stroke in the polyline from patterns input -/// -/// @param patterns An array of object representing the pattern params in the polyline. -/// @return Array of lengths. -+ (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns; - @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 99439c48dd2d..25504291192e 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 @@ -54,7 +54,34 @@ CLLocationCoordinate2D FGMGetCoordinateForPigeonLatLng(FGMPlatformLatLng *latLng viewingAngle:position.tilt]; } -extern GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { +NSArray *FGMGetPointsForPigeonLatLngs(NSArray *pigeonPoints) { + NSMutableArray *points = [[NSMutableArray alloc] initWithCapacity:pigeonPoints.count]; + for (FGMPlatformLatLng *point in pigeonPoints) { + [points addObject:[[CLLocation alloc] initWithLatitude:point.latitude + longitude:point.longitude]]; + } + return points; +} + +NSArray *> *FGMGetHolesForPigeonLatLngArrays( + NSArray *> *pigeonHolePoints) { + NSMutableArray *> *holes = + [[NSMutableArray alloc] initWithCapacity:pigeonHolePoints.count]; + for (NSArray *holePoints in pigeonHolePoints) { + [holes addObject:FGMGetPointsForPigeonLatLngs(holePoints)]; + } + return holes; +} + +GMSMutablePath *FGMGetPathFromPoints(NSArray *points) { + GMSMutablePath *path = [GMSMutablePath path]; + for (CLLocation *location in points) { + [path addCoordinate:location.coordinate]; + } + return path; +} + +GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { switch (type) { case FGMPlatformMapTypeNone: return kGMSTypeNone; @@ -86,6 +113,77 @@ extern GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) markerIds:markerIDs]; } +GMSCameraUpdate *FGMGetCameraUpdateForPigeonCameraUpdate(FGMPlatformCameraUpdate *cameraUpdate) { + // See note in messages.dart for why this is so loosely typed. + id update = cameraUpdate.cameraUpdate; + if ([update isKindOfClass:[FGMPlatformCameraUpdateNewCameraPosition class]]) { + return [GMSCameraUpdate + setCamera:FGMGetCameraPositionForPigeonCameraPosition( + ((FGMPlatformCameraUpdateNewCameraPosition *)update).cameraPosition)]; + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateNewLatLng class]]) { + return [GMSCameraUpdate setTarget:FGMGetCoordinateForPigeonLatLng( + ((FGMPlatformCameraUpdateNewLatLng *)update).latLng)]; + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateNewLatLngBounds class]]) { + FGMPlatformCameraUpdateNewLatLngBounds *typedUpdate = + (FGMPlatformCameraUpdateNewLatLngBounds *)update; + return + [GMSCameraUpdate fitBounds:FGMGetCoordinateBoundsForPigeonLatLngBounds(typedUpdate.bounds) + withPadding:typedUpdate.padding]; + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateNewLatLngZoom class]]) { + FGMPlatformCameraUpdateNewLatLngZoom *typedUpdate = + (FGMPlatformCameraUpdateNewLatLngZoom *)update; + return [GMSCameraUpdate setTarget:FGMGetCoordinateForPigeonLatLng(typedUpdate.latLng) + zoom:typedUpdate.zoom]; + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateScrollBy class]]) { + FGMPlatformCameraUpdateScrollBy *typedUpdate = (FGMPlatformCameraUpdateScrollBy *)update; + return [GMSCameraUpdate scrollByX:typedUpdate.dx Y:typedUpdate.dy]; + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateZoomBy class]]) { + FGMPlatformCameraUpdateZoomBy *typedUpdate = (FGMPlatformCameraUpdateZoomBy *)update; + if (typedUpdate.focus) { + return [GMSCameraUpdate zoomBy:typedUpdate.amount + atPoint:FGMGetCGPointForPigeonPoint(typedUpdate.focus)]; + } else { + return [GMSCameraUpdate zoomBy:typedUpdate.amount]; + } + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateZoom class]]) { + if (((FGMPlatformCameraUpdateZoom *)update).out) { + return [GMSCameraUpdate zoomOut]; + } else { + return [GMSCameraUpdate zoomIn]; + } + } else if ([update isKindOfClass:[FGMPlatformCameraUpdateZoomTo class]]) { + return [GMSCameraUpdate zoomTo:((FGMPlatformCameraUpdateZoomTo *)update).zoom]; + } + return nil; +} + +UIColor *FGMGetColorForRGBA(NSInteger rgba) { + return [UIColor colorWithRed:((CGFloat)((rgba & 0xFF0000) >> 16)) / 255.0 + green:((CGFloat)((rgba & 0xFF00) >> 8)) / 255.0 + blue:((CGFloat)(rgba & 0xFF)) / 255.0 + alpha:((CGFloat)((rgba & 0xFF000000) >> 24)) / 255.0]; +} + +NSArray *FGMGetStrokeStylesFromPatterns( + NSArray *patterns, UIColor *strokeColor) { + NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; + for (FGMPlatformPatternItem *pattern in patterns) { + UIColor *color = + pattern.type == FGMPlatformPatternItemTypeGap ? UIColor.clearColor : strokeColor; + [strokeStyles addObject:[GMSStrokeStyle solidColor:color]]; + } + return strokeStyles; +} + +NSArray *FGMGetSpanLengthsFromPatterns(NSArray *patterns) { + NSMutableArray *lengths = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; + for (FGMPlatformPatternItem *pattern in patterns) { + NSNumber *length = pattern.length ?: @0; + [lengths addObject:length]; + } + return lengths; +} + @implementation FLTGoogleMapJSONConversions // These constants must match the corresponding constants in serialization.dart @@ -114,11 +212,7 @@ + (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location { } + (UIColor *)colorFromRGBA:(NSNumber *)numberColor { - unsigned long value = [numberColor unsignedLongValue]; - return [UIColor colorWithRed:((float)((value & 0xFF0000) >> 16)) / 255.0 - green:((float)((value & 0xFF00) >> 8)) / 255.0 - blue:((float)(value & 0xFF)) / 255.0 - alpha:((float)((value & 0xFF000000) >> 24)) / 255.0]; + return FGMGetColorForRGBA(numberColor.unsignedLongValue); } + (NSNumber *)RGBAFromColor:(UIColor *)color { @@ -129,104 +223,6 @@ + (NSNumber *)RGBAFromColor:(UIColor *)color { return @(value); } -+ (NSArray *)pointsFromLatLongs:(NSArray *)data { - NSMutableArray *points = [[NSMutableArray alloc] init]; - for (unsigned i = 0; i < [data count]; i++) { - NSNumber *latitude = data[i][0]; - NSNumber *longitude = data[i][1]; - CLLocation *point = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] - longitude:[longitude doubleValue]]; - [points addObject:point]; - } - - return points; -} - -+ (NSArray *> *)holesFromPointsArray:(NSArray *)data { - NSMutableArray *> *holes = [[[NSMutableArray alloc] init] init]; - for (unsigned i = 0; i < [data count]; i++) { - NSArray *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:data[i]]; - [holes addObject:points]; - } - - return holes; -} - -+ (nullable GMSCameraPosition *)cameraPostionFromDictionary:(nullable NSDictionary *)data { - if (!data) { - return nil; - } - return [GMSCameraPosition - cameraWithTarget:[FLTGoogleMapJSONConversions locationFromLatLong:data[@"target"]] - zoom:[data[@"zoom"] floatValue] - bearing:[data[@"bearing"] doubleValue] - viewingAngle:[data[@"tilt"] doubleValue]]; -} - -+ (GMSCoordinateBounds *)coordinateBoundsFromLatLongs:(NSArray *)latlongs { - return [[GMSCoordinateBounds alloc] - initWithCoordinate:[FLTGoogleMapJSONConversions locationFromLatLong:latlongs[0]] - coordinate:[FLTGoogleMapJSONConversions locationFromLatLong:latlongs[1]]]; -} - -+ (nullable GMSCameraUpdate *)cameraUpdateFromArray:(NSArray *)channelValue { - NSString *update = channelValue[0]; - if ([update isEqualToString:@"newCameraPosition"]) { - return [GMSCameraUpdate - setCamera:[FLTGoogleMapJSONConversions cameraPostionFromDictionary:channelValue[1]]]; - } else if ([update isEqualToString:@"newLatLng"]) { - return [GMSCameraUpdate - setTarget:[FLTGoogleMapJSONConversions locationFromLatLong:channelValue[1]]]; - } else if ([update isEqualToString:@"newLatLngBounds"]) { - return [GMSCameraUpdate - fitBounds:[FLTGoogleMapJSONConversions coordinateBoundsFromLatLongs:channelValue[1]] - withPadding:[channelValue[2] doubleValue]]; - } else if ([update isEqualToString:@"newLatLngZoom"]) { - return - [GMSCameraUpdate setTarget:[FLTGoogleMapJSONConversions locationFromLatLong:channelValue[1]] - zoom:[channelValue[2] floatValue]]; - } else if ([update isEqualToString:@"scrollBy"]) { - return [GMSCameraUpdate scrollByX:[channelValue[1] doubleValue] - Y:[channelValue[2] doubleValue]]; - } else if ([update isEqualToString:@"zoomBy"]) { - if (channelValue.count == 2) { - return [GMSCameraUpdate zoomBy:[channelValue[1] floatValue]]; - } else { - return [GMSCameraUpdate zoomBy:[channelValue[1] floatValue] - atPoint:[FLTGoogleMapJSONConversions pointFromArray:channelValue[2]]]; - } - } else if ([update isEqualToString:@"zoomIn"]) { - return [GMSCameraUpdate zoomIn]; - } else if ([update isEqualToString:@"zoomOut"]) { - return [GMSCameraUpdate zoomOut]; - } else if ([update isEqualToString:@"zoomTo"]) { - return [GMSCameraUpdate zoomTo:[channelValue[1] floatValue]]; - } - return nil; -} - -+ (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns - strokeColor:(UIColor *)strokeColor { - NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; - for (NSArray *pattern in patterns) { - NSString *patternType = pattern[0]; - UIColor *color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; - [strokeStyles addObject:[GMSStrokeStyle solidColor:color]]; - } - - return strokeStyles; -} - -+ (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns { - NSMutableArray *lengths = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; - for (NSArray *pattern in patterns) { - NSNumber *length = [pattern count] > 1 ? pattern[1] : @0; - [lengths addObject:length]; - } - - return lengths; -} - + (GMUWeightedLatLng *)weightedLatLngFromArray:(NSArray *)data { NSAssert(data.count == 2, @"WeightedLatLng data must have length of 2"); if (data.count != 2) { diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.h index 223de202bfc8..924c4475d493 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.h @@ -13,9 +13,9 @@ NS_ASSUME_NONNULL_BEGIN /// The layer managed by this controller instance. @property(readonly, nonatomic) GMSTileLayer *layer; -- (instancetype)initWithTileLayer:(GMSTileLayer *)tileLayer - mapView:(GMSMapView *)mapView - options:(NSDictionary *)optionsData; +- (instancetype)initWithTileOverlay:(FGMPlatformTileOverlay *)tileOverlay + tileLayer:(GMSTileLayer *)tileLayer + mapView:(GMSMapView *)mapView; - (void)removeTileOverlay; - (void)clearTileCache; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m index 9897cd93da64..37b2f8b6311e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m @@ -14,14 +14,15 @@ @interface FLTGoogleMapTileOverlayController () @implementation FLTGoogleMapTileOverlayController -- (instancetype)initWithTileLayer:(GMSTileLayer *)tileLayer - mapView:(GMSMapView *)mapView - options:(NSDictionary *)optionsData { +- (instancetype)initWithTileOverlay:(FGMPlatformTileOverlay *)tileOverlay + tileLayer:(GMSTileLayer *)tileLayer + mapView:(GMSMapView *)mapView { self = [super init]; if (self) { _layer = tileLayer; _mapView = mapView; - [self interpretTileOverlayOptions:optionsData]; + // TODO(stuartmorgan: Refactor to avoid this call to an instance method in init. + [self updateFromPlatformTileOverlay:tileOverlay]; } return self; } @@ -55,34 +56,12 @@ - (void)setTileSize:(NSInteger)tileSize { self.layer.tileSize = tileSize; } -- (void)interpretTileOverlayOptions:(NSDictionary *)data { - if (!data) { - return; - } - NSNumber *visible = FGMGetValueOrNilFromDict(data, @"visible"); - if (visible) { - [self setVisible:visible.boolValue]; - } - - NSNumber *transparency = FGMGetValueOrNilFromDict(data, @"transparency"); - if (transparency) { - [self setTransparency:transparency.floatValue]; - } - - NSNumber *zIndex = FGMGetValueOrNilFromDict(data, @"zIndex"); - if (zIndex) { - [self setZIndex:zIndex.intValue]; - } - - NSNumber *fadeIn = FGMGetValueOrNilFromDict(data, @"fadeIn"); - if (fadeIn) { - [self setFadeIn:fadeIn.boolValue]; - } - - NSNumber *tileSize = FGMGetValueOrNilFromDict(data, @"tileSize"); - if (tileSize) { - [self setTileSize:tileSize.integerValue]; - } +- (void)updateFromPlatformTileOverlay:(FGMPlatformTileOverlay *)overlay { + [self setVisible:overlay.visible]; + [self setTransparency:overlay.transparency]; + [self setZIndex:(int)overlay.zIndex]; + [self setFadeIn:overlay.fadeIn]; + [self setTileSize:overlay.tileSize]; } @end @@ -182,24 +161,24 @@ - (instancetype)initWithMapView:(GMSMapView *)mapView - (void)addTileOverlays:(NSArray *)tileOverlaysToAdd { for (FGMPlatformTileOverlay *tileOverlay in tileOverlaysToAdd) { - NSString *identifier = [FLTTileOverlaysController identifierForTileOverlay:tileOverlay.json]; + NSString *identifier = tileOverlay.tileOverlayId; FLTTileProviderController *tileProvider = [[FLTTileProviderController alloc] initWithTileOverlayIdentifier:identifier callbackHandler:self.callbackHandler]; FLTGoogleMapTileOverlayController *controller = - [[FLTGoogleMapTileOverlayController alloc] initWithTileLayer:tileProvider - mapView:self.mapView - options:tileOverlay.json]; + [[FLTGoogleMapTileOverlayController alloc] initWithTileOverlay:tileOverlay + tileLayer:tileProvider + mapView:self.mapView]; self.tileOverlayIdentifierToController[identifier] = controller; } } - (void)changeTileOverlays:(NSArray *)tileOverlaysToChange { for (FGMPlatformTileOverlay *tileOverlay in tileOverlaysToChange) { - NSString *identifier = [FLTTileOverlaysController identifierForTileOverlay:tileOverlay.json]; + NSString *identifier = tileOverlay.tileOverlayId; FLTGoogleMapTileOverlayController *controller = self.tileOverlayIdentifierToController[identifier]; - [controller interpretTileOverlayOptions:tileOverlay.json]; + [controller updateFromPlatformTileOverlay:tileOverlay]; } } - (void)removeTileOverlayWithIdentifiers:(NSArray *)identifiers { @@ -224,8 +203,4 @@ - (nullable FLTGoogleMapTileOverlayController *)tileOverlayWithIdentifier:(NSStr return self.tileOverlayIdentifierToController[identifier]; } -+ (NSString *)identifierForTileOverlay:(NSDictionary *)tileOverlay { - return tileOverlay[@"tileOverlayId"]; -} - @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.h index c40340e08db4..3262b37317f2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.h @@ -9,11 +9,8 @@ // Defines circle controllable by Flutter. @interface FLTGoogleMapCircleController : NSObject -- (instancetype)initCircleWithPosition:(CLLocationCoordinate2D)position - radius:(CLLocationDistance)radius - circleId:(NSString *)circleIdentifier - mapView:(GMSMapView *)mapView - options:(NSDictionary *)options; +- (instancetype)initCircleWithPlatformCircle:(FGMPlatformCircle *)circle + mapView:(GMSMapView *)mapView; - (void)removeCircle; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m index ca71d3150221..683538a67eea 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m @@ -14,17 +14,16 @@ @interface FLTGoogleMapCircleController () @implementation FLTGoogleMapCircleController -- (instancetype)initCircleWithPosition:(CLLocationCoordinate2D)position - radius:(CLLocationDistance)radius - circleId:(NSString *)circleIdentifier - mapView:(GMSMapView *)mapView - options:(NSDictionary *)options { +- (instancetype)initCircleWithPlatformCircle:(FGMPlatformCircle *)circle + mapView:(GMSMapView *)mapView { self = [super init]; if (self) { - _circle = [GMSCircle circleWithPosition:position radius:radius]; + _circle = [GMSCircle circleWithPosition:FGMGetCoordinateForPigeonLatLng(circle.center) + radius:circle.radius]; _mapView = mapView; - _circle.userData = @[ circleIdentifier ]; - [self interpretCircleOptions:options]; + _circle.userData = @[ circle.circleId ]; + // TODO(stuartmorgan: Refactor to avoid this call to an instance method in init. + [self updateFromPlatformCircle:circle]; } return self; } @@ -59,46 +58,15 @@ - (void)setFillColor:(UIColor *)color { self.circle.fillColor = color; } -- (void)interpretCircleOptions:(NSDictionary *)data { - NSNumber *consumeTapEvents = FGMGetValueOrNilFromDict(data, @"consumeTapEvents"); - if (consumeTapEvents) { - [self setConsumeTapEvents:consumeTapEvents.boolValue]; - } - - NSNumber *visible = FGMGetValueOrNilFromDict(data, @"visible"); - if (visible) { - [self setVisible:[visible boolValue]]; - } - - NSNumber *zIndex = FGMGetValueOrNilFromDict(data, @"zIndex"); - if (zIndex) { - [self setZIndex:[zIndex intValue]]; - } - - NSArray *center = FGMGetValueOrNilFromDict(data, @"center"); - if (center) { - [self setCenter:[FLTGoogleMapJSONConversions locationFromLatLong:center]]; - } - - NSNumber *radius = FGMGetValueOrNilFromDict(data, @"radius"); - if (radius) { - [self setRadius:[radius floatValue]]; - } - - NSNumber *strokeColor = FGMGetValueOrNilFromDict(data, @"strokeColor"); - if (strokeColor) { - [self setStrokeColor:[FLTGoogleMapJSONConversions colorFromRGBA:strokeColor]]; - } - - NSNumber *strokeWidth = FGMGetValueOrNilFromDict(data, @"strokeWidth"); - if (strokeWidth) { - [self setStrokeWidth:[strokeWidth intValue]]; - } - - NSNumber *fillColor = FGMGetValueOrNilFromDict(data, @"fillColor"); - if (fillColor) { - [self setFillColor:[FLTGoogleMapJSONConversions colorFromRGBA:fillColor]]; - } +- (void)updateFromPlatformCircle:(FGMPlatformCircle *)platformCircle { + [self setConsumeTapEvents:platformCircle.consumeTapEvents]; + [self setVisible:platformCircle.visible]; + [self setZIndex:platformCircle.zIndex]; + [self setCenter:FGMGetCoordinateForPigeonLatLng(platformCircle.center)]; + [self setRadius:platformCircle.radius]; + [self setStrokeColor:FGMGetColorForRGBA(platformCircle.strokeColor)]; + [self setStrokeWidth:platformCircle.strokeWidth]; + [self setFillColor:FGMGetColorForRGBA(platformCircle.fillColor)]; } @end @@ -127,24 +95,17 @@ - (instancetype)initWithMapView:(GMSMapView *)mapView - (void)addCircles:(NSArray *)circlesToAdd { for (FGMPlatformCircle *circle in circlesToAdd) { - CLLocationCoordinate2D position = [FLTCirclesController getPosition:circle.json]; - CLLocationDistance radius = [FLTCirclesController getRadius:circle.json]; - NSString *circleId = [FLTCirclesController getCircleId:circle.json]; FLTGoogleMapCircleController *controller = - [[FLTGoogleMapCircleController alloc] initCircleWithPosition:position - radius:radius - circleId:circleId - mapView:self.mapView - options:circle.json]; - self.circleIdToController[circleId] = controller; + [[FLTGoogleMapCircleController alloc] initCircleWithPlatformCircle:circle + mapView:self.mapView]; + self.circleIdToController[circle.circleId] = controller; } } - (void)changeCircles:(NSArray *)circlesToChange { for (FGMPlatformCircle *circle in circlesToChange) { - NSString *circleId = [FLTCirclesController getCircleId:circle.json]; - FLTGoogleMapCircleController *controller = self.circleIdToController[circleId]; - [controller interpretCircleOptions:circle.json]; + FLTGoogleMapCircleController *controller = self.circleIdToController[circle.circleId]; + [controller updateFromPlatformCircle:circle]; } } @@ -179,18 +140,4 @@ - (void)didTapCircleWithIdentifier:(NSString *)identifier { }]; } -+ (CLLocationCoordinate2D)getPosition:(NSDictionary *)circle { - NSArray *center = circle[@"center"]; - return [FLTGoogleMapJSONConversions locationFromLatLong:center]; -} - -+ (CLLocationDistance)getRadius:(NSDictionary *)circle { - NSNumber *radius = circle[@"radius"]; - return [radius floatValue]; -} - -+ (NSString *)getCircleId:(NSDictionary *)circle { - return circle[@"circleId"]; -} - @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m index 8f913c464219..0108a3f72b2a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m @@ -645,11 +645,11 @@ - (nullable FGMPlatformLatLngBounds *)visibleMapRegion: - (void)moveCameraWithUpdate:(nonnull FGMPlatformCameraUpdate *)cameraUpdate error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { - GMSCameraUpdate *update = [FLTGoogleMapJSONConversions cameraUpdateFromArray:cameraUpdate.json]; + GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate(cameraUpdate); if (!update) { *error = [FlutterError errorWithCode:@"Invalid update" message:@"Unrecognized camera update" - details:cameraUpdate.json]; + details:nil]; return; } [self.controller.mapView moveCamera:update]; @@ -657,11 +657,11 @@ - (void)moveCameraWithUpdate:(nonnull FGMPlatformCameraUpdate *)cameraUpdate - (void)animateCameraWithUpdate:(nonnull FGMPlatformCameraUpdate *)cameraUpdate error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { - GMSCameraUpdate *update = [FLTGoogleMapJSONConversions cameraUpdateFromArray:cameraUpdate.json]; + GMSCameraUpdate *update = FGMGetCameraUpdateForPigeonCameraUpdate(cameraUpdate); if (!update) { *error = [FlutterError errorWithCode:@"Invalid update" message:@"Unrecognized camera update" - details:cameraUpdate.json]; + details:nil]; return; } [self.controller.mapView animateWithCameraUpdate:update]; 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 648ac9f37330..cfbc9392159f 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 @@ -106,51 +106,22 @@ - (void)setZIndex:(int)zIndex { self.marker.zIndex = zIndex; } -- (void)interpretMarkerOptions:(NSDictionary *)data - registrar:(NSObject *)registrar - screenScale:(CGFloat)screenScale { - NSNumber *alpha = FGMGetValueOrNilFromDict(data, @"alpha"); - if (alpha) { - [self setAlpha:[alpha floatValue]]; - } - NSArray *anchor = FGMGetValueOrNilFromDict(data, @"anchor"); - if (anchor) { - [self setAnchor:[FLTGoogleMapJSONConversions pointFromArray:anchor]]; - } - NSNumber *draggable = FGMGetValueOrNilFromDict(data, @"draggable"); - if (draggable) { - [self setDraggable:[draggable boolValue]]; - } - NSArray *icon = FGMGetValueOrNilFromDict(data, @"icon"); - if (icon) { - UIImage *image = [self extractIconFromData:icon registrar:registrar screenScale:screenScale]; - [self setIcon:image]; - } - NSNumber *flat = FGMGetValueOrNilFromDict(data, @"flat"); - if (flat) { - [self setFlat:[flat boolValue]]; - } - NSNumber *consumeTapEvents = FGMGetValueOrNilFromDict(data, @"consumeTapEvents"); - if (consumeTapEvents) { - [self setConsumeTapEvents:[consumeTapEvents boolValue]]; - } - [self interpretInfoWindow:data]; - NSArray *position = FGMGetValueOrNilFromDict(data, @"position"); - if (position) { - [self setPosition:[FLTGoogleMapJSONConversions locationFromLatLong:position]]; - } - NSNumber *rotation = FGMGetValueOrNilFromDict(data, @"rotation"); - if (rotation) { - [self setRotation:[rotation doubleValue]]; - } - NSNumber *visible = FGMGetValueOrNilFromDict(data, @"visible"); - if (visible) { - [self setVisible:[visible boolValue]]; - } - NSNumber *zIndex = FGMGetValueOrNilFromDict(data, @"zIndex"); - if (zIndex) { - [self setZIndex:[zIndex intValue]]; - } +- (void)updateFromPlatformMarker:(FGMPlatformMarker *)platformMarker + registrar:(NSObject *)registrar + screenScale:(CGFloat)screenScale { + [self setAlpha:platformMarker.alpha]; + [self setAnchor:FGMGetCGPointForPigeonPoint(platformMarker.anchor)]; + [self setDraggable:platformMarker.draggable]; + UIImage *image = [self iconFromBitmap:platformMarker.icon + registrar:registrar + screenScale:screenScale]; + [self setIcon:image]; + [self setFlat:platformMarker.flat]; + [self setConsumeTapEvents:platformMarker.consumeTapEvents]; + [self setPosition:FGMGetCoordinateForPigeonLatLng(platformMarker.position)]; + [self setRotation:platformMarker.rotation]; + [self setVisible:platformMarker.visible]; + [self setZIndex:platformMarker.zIndex]; } - (void)interpretInfoWindow:(NSDictionary *)data { @@ -168,86 +139,57 @@ - (void)interpretInfoWindow:(NSDictionary *)data { } } -- (UIImage *)extractIconFromData:(NSArray *)iconData - registrar:(NSObject *)registrar - screenScale:(CGFloat)screenScale { +- (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap + registrar:(NSObject *)registrar + screenScale:(CGFloat)screenScale { NSAssert(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; UIImage *image; - if ([iconData.firstObject isEqualToString:@"defaultMarker"]) { - CGFloat hue = (iconData.count == 1) ? 0.0f : [iconData[1] doubleValue]; + if ([bitmap isKindOfClass:[FGMPlatformBitmapDefaultMarker class]]) { + FGMPlatformBitmapDefaultMarker *bitmapDefaultMarker = bitmap; + CGFloat hue = bitmapDefaultMarker.hue.doubleValue; image = [GMSMarker markerImageWithColor:[UIColor colorWithHue:hue / 360.0 saturation:1.0 brightness:0.7 alpha:1.0]]; - } else if ([iconData.firstObject isEqualToString:@"fromAsset"]) { + } else if ([bitmap isKindOfClass:[FGMPlatformBitmapAsset class]]) { // Deprecated: This message handling for 'fromAsset' has been replaced by 'asset'. // Refer to the flutter google_maps_flutter_platform_interface package for details. - if (iconData.count == 2) { - image = [UIImage imageNamed:[registrar lookupKeyForAsset:iconData[1]]]; + FGMPlatformBitmapAsset *bitmapAsset = bitmap; + if (bitmapAsset.pkg) { + image = [UIImage imageNamed:[registrar lookupKeyForAsset:bitmapAsset.name + fromPackage:bitmapAsset.pkg]]; } else { - image = [UIImage imageNamed:[registrar lookupKeyForAsset:iconData[1] - fromPackage:iconData[2]]]; + image = [UIImage imageNamed:[registrar lookupKeyForAsset:bitmapAsset.name]]; } - } else if ([iconData.firstObject isEqualToString:@"fromAssetImage"]) { + } else if ([bitmap isKindOfClass:[FGMPlatformBitmapAssetImage class]]) { // Deprecated: This message handling for 'fromAssetImage' has been replaced by 'asset'. // Refer to the flutter google_maps_flutter_platform_interface package for details. - if (iconData.count == 3) { - image = [UIImage imageNamed:[registrar lookupKeyForAsset:iconData[1]]]; - id scaleParam = iconData[2]; - image = [self scaleImage:image by:scaleParam]; - } else { - NSString *error = - [NSString stringWithFormat:@"'fromAssetImage' should have exactly 3 arguments. Got: %lu", - (unsigned long)iconData.count]; - NSException *exception = [NSException exceptionWithName:@"InvalidBitmapDescriptor" - reason:error - userInfo:nil]; - @throw exception; - } - } else if ([iconData[0] isEqualToString:@"fromBytes"]) { + FGMPlatformBitmapAssetImage *bitmapAssetImage = bitmap; + image = [UIImage imageNamed:[registrar lookupKeyForAsset:bitmapAssetImage.name]]; + image = [self scaleImage:image by: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. - if (iconData.count == 2) { - @try { - FlutterStandardTypedData *byteData = iconData[1]; - CGFloat mainScreenScale = [[UIScreen mainScreen] scale]; - image = [UIImage imageWithData:[byteData data] scale:mainScreenScale]; - } @catch (NSException *exception) { - @throw [NSException exceptionWithName:@"InvalidByteDescriptor" - reason:@"Unable to interpret bytes as a valid image." - userInfo:nil]; - } - } else { - NSString *error = [NSString - stringWithFormat:@"fromBytes should have exactly one argument, the bytes. Got: %lu", - (unsigned long)iconData.count]; - NSException *exception = [NSException exceptionWithName:@"InvalidByteDescriptor" - reason:error - userInfo:nil]; - @throw exception; - } - } else if ([iconData.firstObject isEqualToString:@"asset"]) { - NSDictionary *assetData = iconData[1]; - if (![assetData isKindOfClass:[NSDictionary class]]) { - NSException *exception = - [NSException exceptionWithName:@"InvalidByteDescriptor" - reason:@"Unable to interpret asset, expected a dictionary as the " - @"second parameter." - userInfo:nil]; - @throw exception; + FGMPlatformBitmapBytes *bitmapBytes = bitmap; + @try { + CGFloat mainScreenScale = [[UIScreen mainScreen] scale]; + image = [UIImage imageWithData:bitmapBytes.byteData.data scale:mainScreenScale]; + } @catch (NSException *exception) { + @throw [NSException exceptionWithName:@"InvalidByteDescriptor" + reason:@"Unable to interpret bytes as a valid image." + userInfo:nil]; } + } else if ([bitmap isKindOfClass:[FGMPlatformBitmapAssetMap class]]) { + FGMPlatformBitmapAssetMap *bitmapAssetMap = bitmap; - NSString *assetName = FGMGetValueOrNilFromDict(assetData, @"assetName"); - NSString *scalingMode = FGMGetValueOrNilFromDict(assetData, @"bitmapScaling"); - - image = [UIImage imageNamed:[registrar lookupKeyForAsset:assetName]]; - - if ([scalingMode isEqualToString:@"auto"]) { - NSNumber *width = FGMGetValueOrNilFromDict(assetData, @"width"); - NSNumber *height = FGMGetValueOrNilFromDict(assetData, @"height"); - CGFloat imagePixelRatio = - [FGMGetValueOrNilFromDict(assetData, @"imagePixelRatio") doubleValue]; + image = [UIImage imageNamed:[registrar lookupKeyForAsset:bitmapAssetMap.assetName]]; + if (bitmapAssetMap.bitmapScaling == FGMPlatformMapBitmapScalingAuto) { + NSNumber *width = bitmapAssetMap.width; + NSNumber *height = bitmapAssetMap.height; if (width || height) { image = [FLTGoogleMapMarkerController scaledImage:image withScale:screenScale]; image = [FLTGoogleMapMarkerController scaledImage:image @@ -255,44 +197,34 @@ - (UIImage *)extractIconFromData:(NSArray *)iconData height:height screenScale:screenScale]; } else { - image = [FLTGoogleMapMarkerController scaledImage:image withScale:imagePixelRatio]; + image = [FLTGoogleMapMarkerController scaledImage:image + withScale:bitmapAssetMap.imagePixelRatio]; } } - } else if ([iconData[0] isEqualToString:@"bytes"]) { - NSDictionary *byteData = iconData[1]; - if (![byteData isKindOfClass:[NSDictionary class]]) { - NSException *exception = - [NSException exceptionWithName:@"InvalidByteDescriptor" - reason:@"Unable to interpret bytes, expected a dictionary as the " - @"second parameter." - userInfo:nil]; - @throw exception; - } - - FlutterStandardTypedData *bytes = FGMGetValueOrNilFromDict(byteData, @"byteData"); - NSString *scalingMode = FGMGetValueOrNilFromDict(byteData, @"bitmapScaling"); + } else if ([bitmap isKindOfClass:[FGMPlatformBitmapBytesMap class]]) { + FGMPlatformBitmapBytesMap *bitmapBytesMap = bitmap; + FlutterStandardTypedData *bytes = bitmapBytesMap.byteData; @try { - image = [UIImage imageWithData:[bytes data] scale:screenScale]; - if ([scalingMode isEqualToString:@"auto"]) { - NSNumber *width = FGMGetValueOrNilFromDict(byteData, @"width"); - NSNumber *height = FGMGetValueOrNilFromDict(byteData, @"height"); - CGFloat imagePixelRatio = - [FGMGetValueOrNilFromDict(byteData, @"imagePixelRatio") doubleValue]; + image = [UIImage imageWithData:bytes.data scale:screenScale]; + if (bitmapBytesMap.bitmapScaling == FGMPlatformMapBitmapScalingAuto) { + NSNumber *width = bitmapBytesMap.width; + NSNumber *height = bitmapBytesMap.height; if (width || height) { - // Before scaling the image, image must be in screenScale + // Before scaling the image, image must be in screenScale. image = [FLTGoogleMapMarkerController scaledImage:image withScale:screenScale]; image = [FLTGoogleMapMarkerController scaledImage:image withWidth:width height:height screenScale:screenScale]; } else { - image = [FLTGoogleMapMarkerController scaledImage:image withScale:imagePixelRatio]; + image = [FLTGoogleMapMarkerController scaledImage:image + withScale:bitmapBytesMap.imagePixelRatio]; } } else { // No scaling, load image from bytes without scale parameter. - image = [UIImage imageWithData:[bytes data]]; + image = [UIImage imageWithData:bytes.data]; } } @catch (NSException *exception) { @throw [NSException exceptionWithName:@"InvalidByteDescriptor" @@ -308,11 +240,7 @@ - (UIImage *)extractIconFromData:(NSArray *)iconData /// 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:(id)scaleParam { - double scale = 1.0; - if ([scaleParam isKindOfClass:[NSNumber class]]) { - scale = [scaleParam doubleValue]; - } +- (UIImage *)scaleImage:(UIImage *)image by:(double)scale { if (fabs(scale - 1) > 1e-3) { return [UIImage imageWithCGImage:[image CGImage] scale:(image.scale * scale) @@ -474,23 +402,23 @@ - (instancetype)initWithMapView:(GMSMapView *)mapView - (void)addMarkers:(NSArray *)markersToAdd { for (FGMPlatformMarker *marker in markersToAdd) { - [self addJSONMarker:marker.json]; + [self addMarker:marker]; } } -- (void)addJSONMarker:(NSDictionary *)markerToAdd { - CLLocationCoordinate2D position = [FLTMarkersController getPosition:markerToAdd]; - NSString *markerIdentifier = markerToAdd[@"markerId"]; - NSString *clusterManagerIdentifier = markerToAdd[@"clusterManagerId"]; +- (void)addMarker:(FGMPlatformMarker *)markerToAdd { + CLLocationCoordinate2D position = FGMGetCoordinateForPigeonLatLng(markerToAdd.position); + NSString *markerIdentifier = markerToAdd.markerId; + NSString *clusterManagerIdentifier = markerToAdd.clusterManagerId; GMSMarker *marker = [GMSMarker markerWithPosition:position]; FLTGoogleMapMarkerController *controller = [[FLTGoogleMapMarkerController alloc] initWithMarker:marker markerIdentifier:markerIdentifier clusterManagerIdentifier:clusterManagerIdentifier mapView:self.mapView]; - [controller interpretMarkerOptions:markerToAdd - registrar:self.registrar - screenScale:[self getScreenScale]]; + [controller updateFromPlatformMarker:markerToAdd + registrar:self.registrar + screenScale:[self getScreenScale]]; if (clusterManagerIdentifier) { GMUClusterManager *clusterManager = [_clusterManagersController clusterManagerWithIdentifier:clusterManagerIdentifier]; @@ -508,8 +436,8 @@ - (void)changeMarkers:(NSArray *)markersToChange { } - (void)changeMarker:(FGMPlatformMarker *)markerToChange { - NSString *markerIdentifier = markerToChange.json[@"markerId"]; - NSString *clusterManagerIdentifier = markerToChange.json[@"clusterManagerId"]; + NSString *markerIdentifier = markerToChange.markerId; + NSString *clusterManagerIdentifier = markerToChange.clusterManagerId; FLTGoogleMapMarkerController *controller = self.markerIdentifierToController[markerIdentifier]; if (!controller) { @@ -518,11 +446,11 @@ - (void)changeMarker:(FGMPlatformMarker *)markerToChange { NSString *previousClusterManagerIdentifier = [controller clusterManagerIdentifier]; if (![previousClusterManagerIdentifier isEqualToString:clusterManagerIdentifier]) { [self removeMarker:markerIdentifier]; - [self addJSONMarker:markerToChange.json]; + [self addMarker:markerToChange]; } else { - [controller interpretMarkerOptions:markerToChange.json - registrar:self.registrar - screenScale:[self getScreenScale]]; + [controller updateFromPlatformMarker:markerToChange + registrar:self.registrar + screenScale:[self getScreenScale]]; } } @@ -664,9 +592,4 @@ - (CGFloat)getScreenScale { return self.mapView.traitCollection.displayScale; } -+ (CLLocationCoordinate2D)getPosition:(NSDictionary *)marker { - NSArray *position = marker[@"position"]; - return [FLTGoogleMapJSONConversions locationFromLatLong:position]; -} - @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController_Test.h index 84e6d0937a28..213f975c5e72 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController_Test.h @@ -8,14 +8,14 @@ /// Extracts an icon image from the iconData array. /// -/// @param iconData An array containing the data for the icon image. +/// @param platformBitmap The Pigeon representation of the icon image. /// @param registrar A Flutter plugin registrar. /// @param screenScale Screen scale factor for scaling bitmaps. Must be greater than 0. /// @return A UIImage object created from the icon data. /// @note Assert unless screenScale is greater than 0. -- (UIImage *)extractIconFromData:(NSArray *)iconData - registrar:(NSObject *)registrar - screenScale:(CGFloat)screenScale; +- (UIImage *)iconFromBitmap:(FGMPlatformBitmap *)platformBitmap + registrar:(NSObject *)registrar + screenScale:(CGFloat)screenScale; /// Checks if an image can be scaled from an original size to a target size using a scale factor /// while maintaining the aspect ratio. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m index a66b7f5d39d7..46d7234c085d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m @@ -40,12 +40,7 @@ - (void)setZIndex:(int)zIndex { self.polygon.zIndex = zIndex; } - (void)setPoints:(NSArray *)points { - GMSMutablePath *path = [GMSMutablePath path]; - - for (CLLocation *location in points) { - [path addCoordinate:location.coordinate]; - } - self.polygon.path = path; + self.polygon.path = FGMGetPathFromPoints(points); } - (void)setHoles:(NSArray *> *)rawHoles { NSMutableArray *holes = [[NSMutableArray alloc] init]; @@ -71,47 +66,16 @@ - (void)setStrokeWidth:(CGFloat)width { self.polygon.strokeWidth = width; } -- (void)interpretPolygonOptions:(NSDictionary *)data - registrar:(NSObject *)registrar { - NSNumber *consumeTapEvents = FGMGetValueOrNilFromDict(data, @"consumeTapEvents"); - if (consumeTapEvents) { - [self setConsumeTapEvents:[consumeTapEvents boolValue]]; - } - - NSNumber *visible = FGMGetValueOrNilFromDict(data, @"visible"); - if (visible) { - [self setVisible:[visible boolValue]]; - } - - NSNumber *zIndex = FGMGetValueOrNilFromDict(data, @"zIndex"); - if (zIndex) { - [self setZIndex:[zIndex intValue]]; - } - - NSArray *points = FGMGetValueOrNilFromDict(data, @"points"); - if (points) { - [self setPoints:[FLTGoogleMapJSONConversions pointsFromLatLongs:points]]; - } - - NSArray *holes = FGMGetValueOrNilFromDict(data, @"holes"); - if (holes) { - [self setHoles:[FLTGoogleMapJSONConversions holesFromPointsArray:holes]]; - } - - NSNumber *fillColor = FGMGetValueOrNilFromDict(data, @"fillColor"); - if (fillColor) { - [self setFillColor:[FLTGoogleMapJSONConversions colorFromRGBA:fillColor]]; - } - - NSNumber *strokeColor = FGMGetValueOrNilFromDict(data, @"strokeColor"); - if (strokeColor) { - [self setStrokeColor:[FLTGoogleMapJSONConversions colorFromRGBA:strokeColor]]; - } - - NSNumber *strokeWidth = FGMGetValueOrNilFromDict(data, @"strokeWidth"); - if (strokeWidth) { - [self setStrokeWidth:[strokeWidth intValue]]; - } +- (void)updateFromPlatformPolygon:(FGMPlatformPolygon *)polygon + registrar:(NSObject *)registrar { + [self setConsumeTapEvents:polygon.consumesTapEvents]; + [self setVisible:polygon.visible]; + [self setZIndex:(int)polygon.zIndex]; + [self setPoints:FGMGetPointsForPigeonLatLngs(polygon.points)]; + [self setHoles:FGMGetHolesForPigeonLatLngArrays(polygon.holes)]; + [self setFillColor:FGMGetColorForRGBA(polygon.fillColor)]; + [self setStrokeColor:FGMGetColorForRGBA(polygon.strokeColor)]; + [self setStrokeWidth:polygon.strokeWidth]; } @end @@ -142,22 +106,22 @@ - (instancetype)initWithMapView:(GMSMapView *)mapView - (void)addPolygons:(NSArray *)polygonsToAdd { for (FGMPlatformPolygon *polygon in polygonsToAdd) { - GMSMutablePath *path = [FLTPolygonsController getPath:polygon.json]; - NSString *identifier = polygon.json[@"polygonId"]; + GMSMutablePath *path = FGMGetPathFromPoints(FGMGetPointsForPigeonLatLngs(polygon.points)); + NSString *identifier = polygon.polygonId; FLTGoogleMapPolygonController *controller = [[FLTGoogleMapPolygonController alloc] initWithPath:path identifier:identifier mapView:self.mapView]; - [controller interpretPolygonOptions:polygon.json registrar:self.registrar]; + [controller updateFromPlatformPolygon:polygon registrar:self.registrar]; self.polygonIdentifierToController[identifier] = controller; } } - (void)changePolygons:(NSArray *)polygonsToChange { for (FGMPlatformPolygon *polygon in polygonsToChange) { - NSString *identifier = polygon.json[@"polygonId"]; + NSString *identifier = polygon.polygonId; FLTGoogleMapPolygonController *controller = self.polygonIdentifierToController[identifier]; - [controller interpretPolygonOptions:polygon.json registrar:self.registrar]; + [controller updateFromPlatformPolygon:polygon registrar:self.registrar]; } } @@ -192,14 +156,4 @@ - (bool)hasPolygonWithIdentifier:(NSString *)identifier { return self.polygonIdentifierToController[identifier] != nil; } -+ (GMSMutablePath *)getPath:(NSDictionary *)polygon { - NSArray *pointArray = polygon[@"points"]; - NSArray *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:pointArray]; - GMSMutablePath *path = [GMSMutablePath path]; - for (CLLocation *location in points) { - [path addCoordinate:location.coordinate]; - } - return path; -} - @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 44a31b18b531..16643b5e7e49 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -63,50 +63,17 @@ - (void)setPattern:(NSArray *)styles lengths:(NSArray *)registrar { - NSNumber *consumeTapEvents = FGMGetValueOrNilFromDict(data, @"consumeTapEvents"); - if (consumeTapEvents) { - [self setConsumeTapEvents:[consumeTapEvents boolValue]]; - } - - NSNumber *visible = FGMGetValueOrNilFromDict(data, @"visible"); - if (visible) { - [self setVisible:[visible boolValue]]; - } - - NSNumber *zIndex = FGMGetValueOrNilFromDict(data, @"zIndex"); - if (zIndex) { - [self setZIndex:[zIndex intValue]]; - } - - NSArray *points = FGMGetValueOrNilFromDict(data, @"points"); - if (points) { - [self setPoints:[FLTGoogleMapJSONConversions pointsFromLatLongs:points]]; - } - - NSNumber *strokeColor = FGMGetValueOrNilFromDict(data, @"color"); - if (strokeColor) { - [self setColor:[FLTGoogleMapJSONConversions colorFromRGBA:strokeColor]]; - } - - NSNumber *strokeWidth = FGMGetValueOrNilFromDict(data, @"width"); - if (strokeWidth) { - [self setStrokeWidth:[strokeWidth intValue]]; - } - - NSNumber *geodesic = FGMGetValueOrNilFromDict(data, @"geodesic"); - if (geodesic) { - [self setGeodesic:geodesic.boolValue]; - } - - NSArray *patterns = FGMGetValueOrNilFromDict(data, @"pattern"); - if (patterns) { - [self - setPattern:[FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns - strokeColor:self.polyline.strokeColor] - lengths:[FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]]; - } +- (void)updateFromPlatformPolyline:(FGMPlatformPolyline *)polyline + registrar:(NSObject *)registrar { + [self setConsumeTapEvents:polyline.consumesTapEvents]; + [self setVisible:polyline.visible]; + [self setZIndex:(int)polyline.zIndex]; + [self setPoints:FGMGetPointsForPigeonLatLngs(polyline.points)]; + [self setColor:FGMGetColorForRGBA(polyline.color)]; + [self setStrokeWidth:polyline.width]; + [self setGeodesic:polyline.geodesic]; + [self setPattern:FGMGetStrokeStylesFromPatterns(polyline.patterns, self.polyline.strokeColor) + lengths:FGMGetSpanLengthsFromPatterns(polyline.patterns)]; } @end @@ -138,22 +105,22 @@ - (instancetype)initWithMapView:(GMSMapView *)mapView - (void)addPolylines:(NSArray *)polylinesToAdd { for (FGMPlatformPolyline *polyline in polylinesToAdd) { - GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline.json]; - NSString *identifier = polyline.json[@"polylineId"]; + GMSMutablePath *path = FGMGetPathFromPoints(FGMGetPointsForPigeonLatLngs(polyline.points)); + NSString *identifier = polyline.polylineId; FLTGoogleMapPolylineController *controller = [[FLTGoogleMapPolylineController alloc] initWithPath:path identifier:identifier mapView:self.mapView]; - [controller interpretPolylineOptions:polyline.json registrar:self.registrar]; + [controller updateFromPlatformPolyline:polyline registrar:self.registrar]; self.polylineIdentifierToController[identifier] = controller; } } - (void)changePolylines:(NSArray *)polylinesToChange { for (FGMPlatformPolyline *polyline in polylinesToChange) { - NSString *identifier = polyline.json[@"polylineId"]; + NSString *identifier = polyline.polylineId; FLTGoogleMapPolylineController *controller = self.polylineIdentifierToController[identifier]; - [controller interpretPolylineOptions:polyline.json registrar:self.registrar]; + [controller updateFromPlatformPolyline:polyline registrar:self.registrar]; } } @@ -188,14 +155,4 @@ - (bool)hasPolylineWithIdentifier:(NSString *)identifier { return self.polylineIdentifierToController[identifier] != nil; } -+ (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline { - NSArray *pointArray = polyline[@"points"]; - NSArray *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:pointArray]; - GMSMutablePath *path = [GMSMutablePath path]; - for (CLLocation *location in points) { - [path addCoordinate:location.coordinate]; - } - return path; -} - @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h index 2b6e91e5d123..295c263beb01 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h @@ -11,14 +11,3 @@ @property(strong, nonatomic) GMSPolyline *polyline; @end - -/// Internal APIs explosed for unit testing -@interface FLTPolylinesController (Test) - -/// Returns the path for polyline based on the points(locations) the polyline has. -/// -/// @param polyline The polyline instance for which path is calculated. -/// @return An instance of GMSMutablePath. -+ (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; - -@end 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 088b8a657147..b8c1bb5c35da 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.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -28,15 +28,63 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { - (instancetype)initWithValue:(FGMPlatformMapType)value; @end +/// Join types for polyline joints. +typedef NS_ENUM(NSUInteger, FGMPlatformJointType) { + FGMPlatformJointTypeMitered = 0, + FGMPlatformJointTypeBevel = 1, + FGMPlatformJointTypeRound = 2, +}; + +/// Wrapper for FGMPlatformJointType to allow for nullability. +@interface FGMPlatformJointTypeBox : NSObject +@property(nonatomic, assign) FGMPlatformJointType value; +- (instancetype)initWithValue:(FGMPlatformJointType)value; +@end + +/// Enumeration of possible types for PatternItem. +typedef NS_ENUM(NSUInteger, FGMPlatformPatternItemType) { + FGMPlatformPatternItemTypeDot = 0, + FGMPlatformPatternItemTypeDash = 1, + FGMPlatformPatternItemTypeGap = 2, +}; + +/// Wrapper for FGMPlatformPatternItemType to allow for nullability. +@interface FGMPlatformPatternItemTypeBox : NSObject +@property(nonatomic, assign) FGMPlatformPatternItemType value; +- (instancetype)initWithValue:(FGMPlatformPatternItemType)value; +@end + +/// Pigeon equivalent of [MapBitmapScaling]. +typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { + FGMPlatformMapBitmapScalingAuto = 0, + FGMPlatformMapBitmapScalingNone = 1, +}; + +/// Wrapper for FGMPlatformMapBitmapScaling to allow for nullability. +@interface FGMPlatformMapBitmapScalingBox : NSObject +@property(nonatomic, assign) FGMPlatformMapBitmapScaling value; +- (instancetype)initWithValue:(FGMPlatformMapBitmapScaling)value; +@end + @class FGMPlatformCameraPosition; @class FGMPlatformCameraUpdate; +@class FGMPlatformCameraUpdateNewCameraPosition; +@class FGMPlatformCameraUpdateNewLatLng; +@class FGMPlatformCameraUpdateNewLatLngBounds; +@class FGMPlatformCameraUpdateNewLatLngZoom; +@class FGMPlatformCameraUpdateScrollBy; +@class FGMPlatformCameraUpdateZoomBy; +@class FGMPlatformCameraUpdateZoom; +@class FGMPlatformCameraUpdateZoomTo; @class FGMPlatformCircle; @class FGMPlatformHeatmap; +@class FGMPlatformInfoWindow; @class FGMPlatformCluster; @class FGMPlatformClusterManager; @class FGMPlatformMarker; @class FGMPlatformPolygon; @class FGMPlatformPolyline; +@class FGMPlatformPatternItem; @class FGMPlatformTile; @class FGMPlatformTileOverlay; @class FGMPlatformEdgeInsets; @@ -46,8 +94,16 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @class FGMPlatformMapViewCreationParams; @class FGMPlatformMapConfiguration; @class FGMPlatformPoint; +@class FGMPlatformSize; @class FGMPlatformTileLayer; @class FGMPlatformZoomRange; +@class FGMPlatformBitmap; +@class FGMPlatformBitmapDefaultMarker; +@class FGMPlatformBitmapBytes; +@class FGMPlatformBitmapAsset; +@class FGMPlatformBitmapAssetImage; +@class FGMPlatformBitmapAssetMap; +@class FGMPlatformBitmapBytesMap; /// Pigeon representatation of a CameraPosition. @interface FGMPlatformCameraPosition : NSObject @@ -67,22 +123,104 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @interface FGMPlatformCameraUpdate : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithJson:(id)json; -/// The update data, as JSON. This should only be set from -/// CameraUpdate.toJson, and the native code must interpret it according to the -/// internal implementation details of the CameraUpdate class. -@property(nonatomic, strong) id json; ++ (instancetype)makeWithCameraUpdate:(id)cameraUpdate; +/// This Object must be one of the classes below prefixed with +/// PlatformCameraUpdate. Each such class represents a different type of +/// camera update, and each holds a different set of data, preventing the +/// use of a single unified class. +@property(nonatomic, strong) id cameraUpdate; +@end + +/// Pigeon equivalent of NewCameraPosition +@interface FGMPlatformCameraUpdateNewCameraPosition : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithCameraPosition:(FGMPlatformCameraPosition *)cameraPosition; +@property(nonatomic, strong) FGMPlatformCameraPosition *cameraPosition; +@end + +/// Pigeon equivalent of NewLatLng +@interface FGMPlatformCameraUpdateNewLatLng : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithLatLng:(FGMPlatformLatLng *)latLng; +@property(nonatomic, strong) FGMPlatformLatLng *latLng; +@end + +/// Pigeon equivalent of NewLatLngBounds +@interface FGMPlatformCameraUpdateNewLatLngBounds : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithBounds:(FGMPlatformLatLngBounds *)bounds padding:(double)padding; +@property(nonatomic, strong) FGMPlatformLatLngBounds *bounds; +@property(nonatomic, assign) double padding; +@end + +/// Pigeon equivalent of NewLatLngZoom +@interface FGMPlatformCameraUpdateNewLatLngZoom : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithLatLng:(FGMPlatformLatLng *)latLng zoom:(double)zoom; +@property(nonatomic, strong) FGMPlatformLatLng *latLng; +@property(nonatomic, assign) double zoom; +@end + +/// Pigeon equivalent of ScrollBy +@interface FGMPlatformCameraUpdateScrollBy : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithDx:(double)dx dy:(double)dy; +@property(nonatomic, assign) double dx; +@property(nonatomic, assign) double dy; +@end + +/// Pigeon equivalent of ZoomBy +@interface FGMPlatformCameraUpdateZoomBy : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithAmount:(double)amount focus:(nullable FGMPlatformPoint *)focus; +@property(nonatomic, assign) double amount; +@property(nonatomic, strong, nullable) FGMPlatformPoint *focus; +@end + +/// Pigeon equivalent of ZoomIn/ZoomOut +@interface FGMPlatformCameraUpdateZoom : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithOut:(BOOL)out; +@property(nonatomic, assign) BOOL out; +@end + +/// Pigeon equivalent of ZoomTo +@interface FGMPlatformCameraUpdateZoomTo : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithZoom:(double)zoom; +@property(nonatomic, assign) double zoom; @end /// Pigeon equivalent of the Circle class. @interface FGMPlatformCircle : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithJson:(id)json; -/// The circle data, as JSON. This should only be set from -/// Circle.toJson, and the native code must interpret it according to the -/// internal implementation details of that method. -@property(nonatomic, strong) id json; ++ (instancetype)makeWithConsumeTapEvents:(BOOL)consumeTapEvents + fillColor:(NSInteger)fillColor + strokeColor:(NSInteger)strokeColor + visible:(BOOL)visible + strokeWidth:(NSInteger)strokeWidth + zIndex:(double)zIndex + center:(FGMPlatformLatLng *)center + radius:(double)radius + circleId:(NSString *)circleId; +@property(nonatomic, assign) BOOL consumeTapEvents; +@property(nonatomic, assign) NSInteger fillColor; +@property(nonatomic, assign) NSInteger strokeColor; +@property(nonatomic, assign) BOOL visible; +@property(nonatomic, assign) NSInteger strokeWidth; +@property(nonatomic, assign) double zIndex; +@property(nonatomic, strong) FGMPlatformLatLng *center; +@property(nonatomic, assign) double radius; +@property(nonatomic, copy) NSString *circleId; @end /// Pigeon equivalent of the Heatmap class. @@ -96,6 +234,18 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @property(nonatomic, strong) id json; @end +/// Pigeon equivalent of the InfoWindow class. +@interface FGMPlatformInfoWindow : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithTitle:(nullable NSString *)title + snippet:(nullable NSString *)snippet + anchor:(FGMPlatformPoint *)anchor; +@property(nonatomic, copy, nullable) NSString *title; +@property(nonatomic, copy, nullable) NSString *snippet; +@property(nonatomic, strong) FGMPlatformPoint *anchor; +@end + /// Pigeon equivalent of Cluster. @interface FGMPlatformCluster : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. @@ -122,33 +272,95 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @interface FGMPlatformMarker : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithJson:(id)json; -/// The marker data, as JSON. This should only be set from -/// Marker.toJson, and the native code must interpret it according to the -/// internal implementation details of that method. -@property(nonatomic, strong) id json; ++ (instancetype)makeWithAlpha:(double)alpha + anchor:(FGMPlatformPoint *)anchor + consumeTapEvents:(BOOL)consumeTapEvents + draggable:(BOOL)draggable + flat:(BOOL)flat + icon:(FGMPlatformBitmap *)icon + infoWindow:(FGMPlatformInfoWindow *)infoWindow + position:(FGMPlatformLatLng *)position + rotation:(double)rotation + visible:(BOOL)visible + zIndex:(double)zIndex + markerId:(NSString *)markerId + clusterManagerId:(nullable NSString *)clusterManagerId; +@property(nonatomic, assign) double alpha; +@property(nonatomic, strong) FGMPlatformPoint *anchor; +@property(nonatomic, assign) BOOL consumeTapEvents; +@property(nonatomic, assign) BOOL draggable; +@property(nonatomic, assign) BOOL flat; +@property(nonatomic, strong) FGMPlatformBitmap *icon; +@property(nonatomic, strong) FGMPlatformInfoWindow *infoWindow; +@property(nonatomic, strong) FGMPlatformLatLng *position; +@property(nonatomic, assign) double rotation; +@property(nonatomic, assign) BOOL visible; +@property(nonatomic, assign) double zIndex; +@property(nonatomic, copy) NSString *markerId; +@property(nonatomic, copy, nullable) NSString *clusterManagerId; @end /// Pigeon equivalent of the Polygon class. @interface FGMPlatformPolygon : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithJson:(id)json; -/// The polygon data, as JSON. This should only be set from -/// Polygon.toJson, and the native code must interpret it according to the -/// internal implementation details of that method. -@property(nonatomic, strong) id json; ++ (instancetype)makeWithPolygonId:(NSString *)polygonId + consumesTapEvents:(BOOL)consumesTapEvents + fillColor:(NSInteger)fillColor + geodesic:(BOOL)geodesic + points:(NSArray *)points + holes:(NSArray *> *)holes + visible:(BOOL)visible + strokeColor:(NSInteger)strokeColor + strokeWidth:(NSInteger)strokeWidth + zIndex:(NSInteger)zIndex; +@property(nonatomic, copy) NSString *polygonId; +@property(nonatomic, assign) BOOL consumesTapEvents; +@property(nonatomic, assign) NSInteger fillColor; +@property(nonatomic, assign) BOOL geodesic; +@property(nonatomic, copy) NSArray *points; +@property(nonatomic, copy) NSArray *> *holes; +@property(nonatomic, assign) BOOL visible; +@property(nonatomic, assign) NSInteger strokeColor; +@property(nonatomic, assign) NSInteger strokeWidth; +@property(nonatomic, assign) NSInteger zIndex; @end /// Pigeon equivalent of the Polyline class. @interface FGMPlatformPolyline : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithJson:(id)json; -/// The polyline data, as JSON. This should only be set from -/// Polyline.toJson, and the native code must interpret it according to the -/// internal implementation details of that method. -@property(nonatomic, strong) id json; ++ (instancetype)makeWithPolylineId:(NSString *)polylineId + consumesTapEvents:(BOOL)consumesTapEvents + color:(NSInteger)color + geodesic:(BOOL)geodesic + jointType:(FGMPlatformJointType)jointType + patterns:(NSArray *)patterns + points:(NSArray *)points + visible:(BOOL)visible + width:(NSInteger)width + zIndex:(NSInteger)zIndex; +@property(nonatomic, copy) NSString *polylineId; +@property(nonatomic, assign) BOOL consumesTapEvents; +@property(nonatomic, assign) NSInteger color; +@property(nonatomic, assign) BOOL geodesic; +/// The joint type. +@property(nonatomic, assign) FGMPlatformJointType jointType; +/// The pattern data, as a list of pattern items. +@property(nonatomic, copy) NSArray *patterns; +@property(nonatomic, copy) NSArray *points; +@property(nonatomic, assign) BOOL visible; +@property(nonatomic, assign) NSInteger width; +@property(nonatomic, assign) NSInteger zIndex; +@end + +/// Pigeon equivalent of the PatternItem class. +@interface FGMPlatformPatternItem : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithType:(FGMPlatformPatternItemType)type length:(nullable NSNumber *)length; +@property(nonatomic, assign) FGMPlatformPatternItemType type; +@property(nonatomic, strong, nullable) NSNumber *length; @end /// Pigeon equivalent of the Tile class. @@ -167,11 +379,18 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @interface FGMPlatformTileOverlay : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithJson:(id)json; -/// The tile overlay data, as JSON. This should only be set from -/// TileOverlay.toJson, and the native code must interpret it according to the -/// internal implementation details of that method. -@property(nonatomic, strong) id json; ++ (instancetype)makeWithTileOverlayId:(NSString *)tileOverlayId + fadeIn:(BOOL)fadeIn + transparency:(double)transparency + zIndex:(NSInteger)zIndex + visible:(BOOL)visible + tileSize:(NSInteger)tileSize; +@property(nonatomic, copy) NSString *tileOverlayId; +@property(nonatomic, assign) BOOL fadeIn; +@property(nonatomic, assign) double transparency; +@property(nonatomic, assign) NSInteger zIndex; +@property(nonatomic, assign) BOOL visible; +@property(nonatomic, assign) NSInteger tileSize; @end /// Pigeon equivalent of Flutter's EdgeInsets. @@ -285,6 +504,15 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @property(nonatomic, assign) double y; @end +/// Pigeon representation of a size. +@interface FGMPlatformSize : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithWidth:(double)width height:(double)height; +@property(nonatomic, assign) double width; +@property(nonatomic, assign) double height; +@end + /// Pigeon equivalent of GMSTileLayer properties. @interface FGMPlatformTileLayer : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. @@ -306,6 +534,98 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapType) { @property(nonatomic, strong, nullable) NSNumber *max; @end +/// Pigeon equivalent of [BitmapDescriptor]. As there are multiple disjoint +/// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which +/// may hold the pigeon equivalent type of any of them. +@interface FGMPlatformBitmap : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithBitmap:(id)bitmap; +/// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], +/// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], +/// [PlatformBitmapBytes], or [PlatformBitmapDefaultMarker]. +/// As Pigeon does not currently support data class inheritance, this +/// approach allows for the different bitmap implementations to be valid +/// argument and return types of the API methods. See +/// https://github.com/flutter/flutter/issues/117819. +@property(nonatomic, strong) id bitmap; +@end + +/// Pigeon equivalent of [DefaultMarker]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float) +@interface FGMPlatformBitmapDefaultMarker : NSObject ++ (instancetype)makeWithHue:(nullable NSNumber *)hue; +@property(nonatomic, strong, nullable) NSNumber *hue; +@end + +/// Pigeon equivalent of [BytesBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap) +@interface FGMPlatformBitmapBytes : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithByteData:(FlutterStandardTypedData *)byteData + size:(nullable FGMPlatformSize *)size; +@property(nonatomic, strong) FlutterStandardTypedData *byteData; +@property(nonatomic, strong, nullable) FGMPlatformSize *size; +@end + +/// Pigeon equivalent of [AssetBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +@interface FGMPlatformBitmapAsset : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithName:(NSString *)name pkg:(nullable NSString *)pkg; +@property(nonatomic, copy) NSString *name; +@property(nonatomic, copy, nullable) NSString *pkg; +@end + +/// Pigeon equivalent of [AssetImageBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +@interface FGMPlatformBitmapAssetImage : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithName:(NSString *)name + scale:(double)scale + size:(nullable FGMPlatformSize *)size; +@property(nonatomic, copy) NSString *name; +@property(nonatomic, assign) double scale; +@property(nonatomic, strong, nullable) FGMPlatformSize *size; +@end + +/// Pigeon equivalent of [AssetMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +@interface FGMPlatformBitmapAssetMap : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithAssetName:(NSString *)assetName + bitmapScaling:(FGMPlatformMapBitmapScaling)bitmapScaling + imagePixelRatio:(double)imagePixelRatio + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height; +@property(nonatomic, copy) NSString *assetName; +@property(nonatomic, assign) FGMPlatformMapBitmapScaling bitmapScaling; +@property(nonatomic, assign) double imagePixelRatio; +@property(nonatomic, strong, nullable) NSNumber *width; +@property(nonatomic, strong, nullable) NSNumber *height; +@end + +/// Pigeon equivalent of [BytesMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image +@interface FGMPlatformBitmapBytesMap : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithByteData:(FlutterStandardTypedData *)byteData + bitmapScaling:(FGMPlatformMapBitmapScaling)bitmapScaling + imagePixelRatio:(double)imagePixelRatio + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height; +@property(nonatomic, strong) FlutterStandardTypedData *byteData; +@property(nonatomic, assign) FGMPlatformMapBitmapScaling bitmapScaling; +@property(nonatomic, assign) double imagePixelRatio; +@property(nonatomic, strong, nullable) NSNumber *width; +@property(nonatomic, strong, nullable) NSNumber *height; +@end + /// The codec used by all APIs. NSObject *FGMGetMessagesCodec(void); 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 73072d76dc70..5d3474cf79cc 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.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.1), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.g.h" @@ -50,6 +50,39 @@ - (instancetype)initWithValue:(FGMPlatformMapType)value { } @end +/// Join types for polyline joints. +@implementation FGMPlatformJointTypeBox +- (instancetype)initWithValue:(FGMPlatformJointType)value { + self = [super init]; + if (self) { + _value = value; + } + return self; +} +@end + +/// Enumeration of possible types for PatternItem. +@implementation FGMPlatformPatternItemTypeBox +- (instancetype)initWithValue:(FGMPlatformPatternItemType)value { + self = [super init]; + if (self) { + _value = value; + } + return self; +} +@end + +/// Pigeon equivalent of [MapBitmapScaling]. +@implementation FGMPlatformMapBitmapScalingBox +- (instancetype)initWithValue:(FGMPlatformMapBitmapScaling)value { + self = [super init]; + if (self) { + _value = value; + } + return self; +} +@end + @interface FGMPlatformCameraPosition () + (FGMPlatformCameraPosition *)fromList:(NSArray *)list; + (nullable FGMPlatformCameraPosition *)nullableFromList:(NSArray *)list; @@ -62,6 +95,54 @@ + (nullable FGMPlatformCameraUpdate *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FGMPlatformCameraUpdateNewCameraPosition () ++ (FGMPlatformCameraUpdateNewCameraPosition *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateNewCameraPosition *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateNewLatLng () ++ (FGMPlatformCameraUpdateNewLatLng *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateNewLatLng *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateNewLatLngBounds () ++ (FGMPlatformCameraUpdateNewLatLngBounds *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateNewLatLngBounds *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateNewLatLngZoom () ++ (FGMPlatformCameraUpdateNewLatLngZoom *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateNewLatLngZoom *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateScrollBy () ++ (FGMPlatformCameraUpdateScrollBy *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateScrollBy *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateZoomBy () ++ (FGMPlatformCameraUpdateZoomBy *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateZoomBy *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateZoom () ++ (FGMPlatformCameraUpdateZoom *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateZoom *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformCameraUpdateZoomTo () ++ (FGMPlatformCameraUpdateZoomTo *)fromList:(NSArray *)list; ++ (nullable FGMPlatformCameraUpdateZoomTo *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FGMPlatformCircle () + (FGMPlatformCircle *)fromList:(NSArray *)list; + (nullable FGMPlatformCircle *)nullableFromList:(NSArray *)list; @@ -74,6 +155,12 @@ + (nullable FGMPlatformHeatmap *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FGMPlatformInfoWindow () ++ (FGMPlatformInfoWindow *)fromList:(NSArray *)list; ++ (nullable FGMPlatformInfoWindow *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FGMPlatformCluster () + (FGMPlatformCluster *)fromList:(NSArray *)list; + (nullable FGMPlatformCluster *)nullableFromList:(NSArray *)list; @@ -104,6 +191,12 @@ + (nullable FGMPlatformPolyline *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FGMPlatformPatternItem () ++ (FGMPlatformPatternItem *)fromList:(NSArray *)list; ++ (nullable FGMPlatformPatternItem *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FGMPlatformTile () + (FGMPlatformTile *)fromList:(NSArray *)list; + (nullable FGMPlatformTile *)nullableFromList:(NSArray *)list; @@ -158,6 +251,12 @@ + (nullable FGMPlatformPoint *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FGMPlatformSize () ++ (FGMPlatformSize *)fromList:(NSArray *)list; ++ (nullable FGMPlatformSize *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FGMPlatformTileLayer () + (FGMPlatformTileLayer *)fromList:(NSArray *)list; + (nullable FGMPlatformTileLayer *)nullableFromList:(NSArray *)list; @@ -170,6 +269,48 @@ + (nullable FGMPlatformZoomRange *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FGMPlatformBitmap () ++ (FGMPlatformBitmap *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmap *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformBitmapDefaultMarker () ++ (FGMPlatformBitmapDefaultMarker *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmapDefaultMarker *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformBitmapBytes () ++ (FGMPlatformBitmapBytes *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmapBytes *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformBitmapAsset () ++ (FGMPlatformBitmapAsset *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmapAsset *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformBitmapAssetImage () ++ (FGMPlatformBitmapAssetImage *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmapAssetImage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformBitmapAssetMap () ++ (FGMPlatformBitmapAssetMap *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmapAssetMap *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface FGMPlatformBitmapBytesMap () ++ (FGMPlatformBitmapBytesMap *)fromList:(NSArray *)list; ++ (nullable FGMPlatformBitmapBytesMap *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @implementation FGMPlatformCameraPosition + (instancetype)makeWithBearing:(double)bearing target:(FGMPlatformLatLng *)target @@ -204,14 +345,14 @@ + (nullable FGMPlatformCameraPosition *)nullableFromList:(NSArray *)list { @end @implementation FGMPlatformCameraUpdate -+ (instancetype)makeWithJson:(id)json { ++ (instancetype)makeWithCameraUpdate:(id)cameraUpdate { FGMPlatformCameraUpdate *pigeonResult = [[FGMPlatformCameraUpdate alloc] init]; - pigeonResult.json = json; + pigeonResult.cameraUpdate = cameraUpdate; return pigeonResult; } + (FGMPlatformCameraUpdate *)fromList:(NSArray *)list { FGMPlatformCameraUpdate *pigeonResult = [[FGMPlatformCameraUpdate alloc] init]; - pigeonResult.json = GetNullableObjectAtIndex(list, 0); + pigeonResult.cameraUpdate = GetNullableObjectAtIndex(list, 0); return pigeonResult; } + (nullable FGMPlatformCameraUpdate *)nullableFromList:(NSArray *)list { @@ -219,20 +360,230 @@ + (nullable FGMPlatformCameraUpdate *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - self.json ?: [NSNull null], + self.cameraUpdate ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformCameraUpdateNewCameraPosition ++ (instancetype)makeWithCameraPosition:(FGMPlatformCameraPosition *)cameraPosition { + FGMPlatformCameraUpdateNewCameraPosition *pigeonResult = + [[FGMPlatformCameraUpdateNewCameraPosition alloc] init]; + pigeonResult.cameraPosition = cameraPosition; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateNewCameraPosition *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateNewCameraPosition *pigeonResult = + [[FGMPlatformCameraUpdateNewCameraPosition alloc] init]; + pigeonResult.cameraPosition = GetNullableObjectAtIndex(list, 0); + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateNewCameraPosition *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateNewCameraPosition fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.cameraPosition ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformCameraUpdateNewLatLng ++ (instancetype)makeWithLatLng:(FGMPlatformLatLng *)latLng { + FGMPlatformCameraUpdateNewLatLng *pigeonResult = [[FGMPlatformCameraUpdateNewLatLng alloc] init]; + pigeonResult.latLng = latLng; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateNewLatLng *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateNewLatLng *pigeonResult = [[FGMPlatformCameraUpdateNewLatLng alloc] init]; + pigeonResult.latLng = GetNullableObjectAtIndex(list, 0); + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateNewLatLng *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateNewLatLng fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.latLng ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformCameraUpdateNewLatLngBounds ++ (instancetype)makeWithBounds:(FGMPlatformLatLngBounds *)bounds padding:(double)padding { + FGMPlatformCameraUpdateNewLatLngBounds *pigeonResult = + [[FGMPlatformCameraUpdateNewLatLngBounds alloc] init]; + pigeonResult.bounds = bounds; + pigeonResult.padding = padding; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateNewLatLngBounds *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateNewLatLngBounds *pigeonResult = + [[FGMPlatformCameraUpdateNewLatLngBounds alloc] init]; + pigeonResult.bounds = GetNullableObjectAtIndex(list, 0); + pigeonResult.padding = [GetNullableObjectAtIndex(list, 1) doubleValue]; + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateNewLatLngBounds *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateNewLatLngBounds fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.bounds ?: [NSNull null], + @(self.padding), + ]; +} +@end + +@implementation FGMPlatformCameraUpdateNewLatLngZoom ++ (instancetype)makeWithLatLng:(FGMPlatformLatLng *)latLng zoom:(double)zoom { + FGMPlatformCameraUpdateNewLatLngZoom *pigeonResult = + [[FGMPlatformCameraUpdateNewLatLngZoom alloc] init]; + pigeonResult.latLng = latLng; + pigeonResult.zoom = zoom; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateNewLatLngZoom *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateNewLatLngZoom *pigeonResult = + [[FGMPlatformCameraUpdateNewLatLngZoom alloc] init]; + pigeonResult.latLng = GetNullableObjectAtIndex(list, 0); + pigeonResult.zoom = [GetNullableObjectAtIndex(list, 1) doubleValue]; + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateNewLatLngZoom *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateNewLatLngZoom fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.latLng ?: [NSNull null], + @(self.zoom), + ]; +} +@end + +@implementation FGMPlatformCameraUpdateScrollBy ++ (instancetype)makeWithDx:(double)dx dy:(double)dy { + FGMPlatformCameraUpdateScrollBy *pigeonResult = [[FGMPlatformCameraUpdateScrollBy alloc] init]; + pigeonResult.dx = dx; + pigeonResult.dy = dy; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateScrollBy *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateScrollBy *pigeonResult = [[FGMPlatformCameraUpdateScrollBy alloc] init]; + pigeonResult.dx = [GetNullableObjectAtIndex(list, 0) doubleValue]; + pigeonResult.dy = [GetNullableObjectAtIndex(list, 1) doubleValue]; + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateScrollBy *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateScrollBy fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.dx), + @(self.dy), + ]; +} +@end + +@implementation FGMPlatformCameraUpdateZoomBy ++ (instancetype)makeWithAmount:(double)amount focus:(nullable FGMPlatformPoint *)focus { + FGMPlatformCameraUpdateZoomBy *pigeonResult = [[FGMPlatformCameraUpdateZoomBy alloc] init]; + pigeonResult.amount = amount; + pigeonResult.focus = focus; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateZoomBy *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateZoomBy *pigeonResult = [[FGMPlatformCameraUpdateZoomBy alloc] init]; + pigeonResult.amount = [GetNullableObjectAtIndex(list, 0) doubleValue]; + pigeonResult.focus = GetNullableObjectAtIndex(list, 1); + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateZoomBy *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateZoomBy fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.amount), + self.focus ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformCameraUpdateZoom ++ (instancetype)makeWithOut:(BOOL)out { + FGMPlatformCameraUpdateZoom *pigeonResult = [[FGMPlatformCameraUpdateZoom alloc] init]; + pigeonResult.out = out; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateZoom *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateZoom *pigeonResult = [[FGMPlatformCameraUpdateZoom alloc] init]; + pigeonResult.out = [GetNullableObjectAtIndex(list, 0) boolValue]; + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateZoom *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateZoom fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.out), + ]; +} +@end + +@implementation FGMPlatformCameraUpdateZoomTo ++ (instancetype)makeWithZoom:(double)zoom { + FGMPlatformCameraUpdateZoomTo *pigeonResult = [[FGMPlatformCameraUpdateZoomTo alloc] init]; + pigeonResult.zoom = zoom; + return pigeonResult; +} ++ (FGMPlatformCameraUpdateZoomTo *)fromList:(NSArray *)list { + FGMPlatformCameraUpdateZoomTo *pigeonResult = [[FGMPlatformCameraUpdateZoomTo alloc] init]; + pigeonResult.zoom = [GetNullableObjectAtIndex(list, 0) doubleValue]; + return pigeonResult; +} ++ (nullable FGMPlatformCameraUpdateZoomTo *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformCameraUpdateZoomTo fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.zoom), ]; } @end @implementation FGMPlatformCircle -+ (instancetype)makeWithJson:(id)json { ++ (instancetype)makeWithConsumeTapEvents:(BOOL)consumeTapEvents + fillColor:(NSInteger)fillColor + strokeColor:(NSInteger)strokeColor + visible:(BOOL)visible + strokeWidth:(NSInteger)strokeWidth + zIndex:(double)zIndex + center:(FGMPlatformLatLng *)center + radius:(double)radius + circleId:(NSString *)circleId { FGMPlatformCircle *pigeonResult = [[FGMPlatformCircle alloc] init]; - pigeonResult.json = json; + pigeonResult.consumeTapEvents = consumeTapEvents; + pigeonResult.fillColor = fillColor; + pigeonResult.strokeColor = strokeColor; + pigeonResult.visible = visible; + pigeonResult.strokeWidth = strokeWidth; + pigeonResult.zIndex = zIndex; + pigeonResult.center = center; + pigeonResult.radius = radius; + pigeonResult.circleId = circleId; return pigeonResult; } + (FGMPlatformCircle *)fromList:(NSArray *)list { FGMPlatformCircle *pigeonResult = [[FGMPlatformCircle alloc] init]; - pigeonResult.json = GetNullableObjectAtIndex(list, 0); + pigeonResult.consumeTapEvents = [GetNullableObjectAtIndex(list, 0) boolValue]; + pigeonResult.fillColor = [GetNullableObjectAtIndex(list, 1) integerValue]; + pigeonResult.strokeColor = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.visible = [GetNullableObjectAtIndex(list, 3) boolValue]; + pigeonResult.strokeWidth = [GetNullableObjectAtIndex(list, 4) integerValue]; + pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 5) doubleValue]; + pigeonResult.center = GetNullableObjectAtIndex(list, 6); + pigeonResult.radius = [GetNullableObjectAtIndex(list, 7) doubleValue]; + pigeonResult.circleId = GetNullableObjectAtIndex(list, 8); return pigeonResult; } + (nullable FGMPlatformCircle *)nullableFromList:(NSArray *)list { @@ -240,7 +591,15 @@ + (nullable FGMPlatformCircle *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - self.json ?: [NSNull null], + @(self.consumeTapEvents), + @(self.fillColor), + @(self.strokeColor), + @(self.visible), + @(self.strokeWidth), + @(self.zIndex), + self.center ?: [NSNull null], + @(self.radius), + self.circleId ?: [NSNull null], ]; } @end @@ -266,6 +625,35 @@ + (nullable FGMPlatformHeatmap *)nullableFromList:(NSArray *)list { } @end +@implementation FGMPlatformInfoWindow ++ (instancetype)makeWithTitle:(nullable NSString *)title + snippet:(nullable NSString *)snippet + anchor:(FGMPlatformPoint *)anchor { + FGMPlatformInfoWindow *pigeonResult = [[FGMPlatformInfoWindow alloc] init]; + pigeonResult.title = title; + pigeonResult.snippet = snippet; + pigeonResult.anchor = anchor; + return pigeonResult; +} ++ (FGMPlatformInfoWindow *)fromList:(NSArray *)list { + FGMPlatformInfoWindow *pigeonResult = [[FGMPlatformInfoWindow alloc] init]; + pigeonResult.title = GetNullableObjectAtIndex(list, 0); + pigeonResult.snippet = GetNullableObjectAtIndex(list, 1); + pigeonResult.anchor = GetNullableObjectAtIndex(list, 2); + return pigeonResult; +} ++ (nullable FGMPlatformInfoWindow *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformInfoWindow fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.title ?: [NSNull null], + self.snippet ?: [NSNull null], + self.anchor ?: [NSNull null], + ]; +} +@end + @implementation FGMPlatformCluster + (instancetype)makeWithClusterManagerId:(NSString *)clusterManagerId position:(FGMPlatformLatLng *)position @@ -321,14 +709,50 @@ + (nullable FGMPlatformClusterManager *)nullableFromList:(NSArray *)list { @end @implementation FGMPlatformMarker -+ (instancetype)makeWithJson:(id)json { ++ (instancetype)makeWithAlpha:(double)alpha + anchor:(FGMPlatformPoint *)anchor + consumeTapEvents:(BOOL)consumeTapEvents + draggable:(BOOL)draggable + flat:(BOOL)flat + icon:(FGMPlatformBitmap *)icon + infoWindow:(FGMPlatformInfoWindow *)infoWindow + position:(FGMPlatformLatLng *)position + rotation:(double)rotation + visible:(BOOL)visible + zIndex:(double)zIndex + markerId:(NSString *)markerId + clusterManagerId:(nullable NSString *)clusterManagerId { FGMPlatformMarker *pigeonResult = [[FGMPlatformMarker alloc] init]; - pigeonResult.json = json; + pigeonResult.alpha = alpha; + pigeonResult.anchor = anchor; + pigeonResult.consumeTapEvents = consumeTapEvents; + pigeonResult.draggable = draggable; + pigeonResult.flat = flat; + pigeonResult.icon = icon; + pigeonResult.infoWindow = infoWindow; + pigeonResult.position = position; + pigeonResult.rotation = rotation; + pigeonResult.visible = visible; + pigeonResult.zIndex = zIndex; + pigeonResult.markerId = markerId; + pigeonResult.clusterManagerId = clusterManagerId; return pigeonResult; } + (FGMPlatformMarker *)fromList:(NSArray *)list { FGMPlatformMarker *pigeonResult = [[FGMPlatformMarker alloc] init]; - pigeonResult.json = GetNullableObjectAtIndex(list, 0); + pigeonResult.alpha = [GetNullableObjectAtIndex(list, 0) doubleValue]; + pigeonResult.anchor = GetNullableObjectAtIndex(list, 1); + pigeonResult.consumeTapEvents = [GetNullableObjectAtIndex(list, 2) boolValue]; + pigeonResult.draggable = [GetNullableObjectAtIndex(list, 3) boolValue]; + pigeonResult.flat = [GetNullableObjectAtIndex(list, 4) boolValue]; + pigeonResult.icon = GetNullableObjectAtIndex(list, 5); + pigeonResult.infoWindow = GetNullableObjectAtIndex(list, 6); + pigeonResult.position = GetNullableObjectAtIndex(list, 7); + pigeonResult.rotation = [GetNullableObjectAtIndex(list, 8) doubleValue]; + pigeonResult.visible = [GetNullableObjectAtIndex(list, 9) boolValue]; + pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 10) doubleValue]; + pigeonResult.markerId = GetNullableObjectAtIndex(list, 11); + pigeonResult.clusterManagerId = GetNullableObjectAtIndex(list, 12); return pigeonResult; } + (nullable FGMPlatformMarker *)nullableFromList:(NSArray *)list { @@ -336,20 +760,59 @@ + (nullable FGMPlatformMarker *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - self.json ?: [NSNull null], + @(self.alpha), + self.anchor ?: [NSNull null], + @(self.consumeTapEvents), + @(self.draggable), + @(self.flat), + self.icon ?: [NSNull null], + self.infoWindow ?: [NSNull null], + self.position ?: [NSNull null], + @(self.rotation), + @(self.visible), + @(self.zIndex), + self.markerId ?: [NSNull null], + self.clusterManagerId ?: [NSNull null], ]; } @end @implementation FGMPlatformPolygon -+ (instancetype)makeWithJson:(id)json { ++ (instancetype)makeWithPolygonId:(NSString *)polygonId + consumesTapEvents:(BOOL)consumesTapEvents + fillColor:(NSInteger)fillColor + geodesic:(BOOL)geodesic + points:(NSArray *)points + holes:(NSArray *> *)holes + visible:(BOOL)visible + strokeColor:(NSInteger)strokeColor + strokeWidth:(NSInteger)strokeWidth + zIndex:(NSInteger)zIndex { FGMPlatformPolygon *pigeonResult = [[FGMPlatformPolygon alloc] init]; - pigeonResult.json = json; + pigeonResult.polygonId = polygonId; + pigeonResult.consumesTapEvents = consumesTapEvents; + pigeonResult.fillColor = fillColor; + pigeonResult.geodesic = geodesic; + pigeonResult.points = points; + pigeonResult.holes = holes; + pigeonResult.visible = visible; + pigeonResult.strokeColor = strokeColor; + pigeonResult.strokeWidth = strokeWidth; + pigeonResult.zIndex = zIndex; return pigeonResult; } + (FGMPlatformPolygon *)fromList:(NSArray *)list { FGMPlatformPolygon *pigeonResult = [[FGMPlatformPolygon alloc] init]; - pigeonResult.json = GetNullableObjectAtIndex(list, 0); + pigeonResult.polygonId = GetNullableObjectAtIndex(list, 0); + pigeonResult.consumesTapEvents = [GetNullableObjectAtIndex(list, 1) boolValue]; + pigeonResult.fillColor = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.geodesic = [GetNullableObjectAtIndex(list, 3) boolValue]; + pigeonResult.points = GetNullableObjectAtIndex(list, 4); + pigeonResult.holes = GetNullableObjectAtIndex(list, 5); + pigeonResult.visible = [GetNullableObjectAtIndex(list, 6) boolValue]; + pigeonResult.strokeColor = [GetNullableObjectAtIndex(list, 7) integerValue]; + pigeonResult.strokeWidth = [GetNullableObjectAtIndex(list, 8) integerValue]; + pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 9) integerValue]; return pigeonResult; } + (nullable FGMPlatformPolygon *)nullableFromList:(NSArray *)list { @@ -357,20 +820,57 @@ + (nullable FGMPlatformPolygon *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - self.json ?: [NSNull null], + self.polygonId ?: [NSNull null], + @(self.consumesTapEvents), + @(self.fillColor), + @(self.geodesic), + self.points ?: [NSNull null], + self.holes ?: [NSNull null], + @(self.visible), + @(self.strokeColor), + @(self.strokeWidth), + @(self.zIndex), ]; } @end @implementation FGMPlatformPolyline -+ (instancetype)makeWithJson:(id)json { ++ (instancetype)makeWithPolylineId:(NSString *)polylineId + consumesTapEvents:(BOOL)consumesTapEvents + color:(NSInteger)color + geodesic:(BOOL)geodesic + jointType:(FGMPlatformJointType)jointType + patterns:(NSArray *)patterns + points:(NSArray *)points + visible:(BOOL)visible + width:(NSInteger)width + zIndex:(NSInteger)zIndex { FGMPlatformPolyline *pigeonResult = [[FGMPlatformPolyline alloc] init]; - pigeonResult.json = json; + pigeonResult.polylineId = polylineId; + pigeonResult.consumesTapEvents = consumesTapEvents; + pigeonResult.color = color; + pigeonResult.geodesic = geodesic; + pigeonResult.jointType = jointType; + pigeonResult.patterns = patterns; + pigeonResult.points = points; + pigeonResult.visible = visible; + pigeonResult.width = width; + pigeonResult.zIndex = zIndex; return pigeonResult; } + (FGMPlatformPolyline *)fromList:(NSArray *)list { FGMPlatformPolyline *pigeonResult = [[FGMPlatformPolyline alloc] init]; - pigeonResult.json = GetNullableObjectAtIndex(list, 0); + pigeonResult.polylineId = GetNullableObjectAtIndex(list, 0); + pigeonResult.consumesTapEvents = [GetNullableObjectAtIndex(list, 1) boolValue]; + pigeonResult.color = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.geodesic = [GetNullableObjectAtIndex(list, 3) boolValue]; + FGMPlatformJointTypeBox *boxedFGMPlatformJointType = GetNullableObjectAtIndex(list, 4); + pigeonResult.jointType = boxedFGMPlatformJointType.value; + pigeonResult.patterns = GetNullableObjectAtIndex(list, 5); + pigeonResult.points = GetNullableObjectAtIndex(list, 6); + pigeonResult.visible = [GetNullableObjectAtIndex(list, 7) boolValue]; + pigeonResult.width = [GetNullableObjectAtIndex(list, 8) integerValue]; + pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 9) integerValue]; return pigeonResult; } + (nullable FGMPlatformPolyline *)nullableFromList:(NSArray *)list { @@ -378,7 +878,42 @@ + (nullable FGMPlatformPolyline *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - self.json ?: [NSNull null], + self.polylineId ?: [NSNull null], + @(self.consumesTapEvents), + @(self.color), + @(self.geodesic), + [[FGMPlatformJointTypeBox alloc] initWithValue:self.jointType], + self.patterns ?: [NSNull null], + self.points ?: [NSNull null], + @(self.visible), + @(self.width), + @(self.zIndex), + ]; +} +@end + +@implementation FGMPlatformPatternItem ++ (instancetype)makeWithType:(FGMPlatformPatternItemType)type length:(nullable NSNumber *)length { + FGMPlatformPatternItem *pigeonResult = [[FGMPlatformPatternItem alloc] init]; + pigeonResult.type = type; + pigeonResult.length = length; + return pigeonResult; +} ++ (FGMPlatformPatternItem *)fromList:(NSArray *)list { + FGMPlatformPatternItem *pigeonResult = [[FGMPlatformPatternItem alloc] init]; + FGMPlatformPatternItemTypeBox *boxedFGMPlatformPatternItemType = + GetNullableObjectAtIndex(list, 0); + pigeonResult.type = boxedFGMPlatformPatternItemType.value; + pigeonResult.length = GetNullableObjectAtIndex(list, 1); + return pigeonResult; +} ++ (nullable FGMPlatformPatternItem *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformPatternItem fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + [[FGMPlatformPatternItemTypeBox alloc] initWithValue:self.type], + self.length ?: [NSNull null], ]; } @end @@ -413,14 +948,29 @@ + (nullable FGMPlatformTile *)nullableFromList:(NSArray *)list { @end @implementation FGMPlatformTileOverlay -+ (instancetype)makeWithJson:(id)json { ++ (instancetype)makeWithTileOverlayId:(NSString *)tileOverlayId + fadeIn:(BOOL)fadeIn + transparency:(double)transparency + zIndex:(NSInteger)zIndex + visible:(BOOL)visible + tileSize:(NSInteger)tileSize { FGMPlatformTileOverlay *pigeonResult = [[FGMPlatformTileOverlay alloc] init]; - pigeonResult.json = json; + pigeonResult.tileOverlayId = tileOverlayId; + pigeonResult.fadeIn = fadeIn; + pigeonResult.transparency = transparency; + pigeonResult.zIndex = zIndex; + pigeonResult.visible = visible; + pigeonResult.tileSize = tileSize; return pigeonResult; } + (FGMPlatformTileOverlay *)fromList:(NSArray *)list { FGMPlatformTileOverlay *pigeonResult = [[FGMPlatformTileOverlay alloc] init]; - pigeonResult.json = GetNullableObjectAtIndex(list, 0); + pigeonResult.tileOverlayId = GetNullableObjectAtIndex(list, 0); + pigeonResult.fadeIn = [GetNullableObjectAtIndex(list, 1) boolValue]; + pigeonResult.transparency = [GetNullableObjectAtIndex(list, 2) doubleValue]; + pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 3) integerValue]; + pigeonResult.visible = [GetNullableObjectAtIndex(list, 4) boolValue]; + pigeonResult.tileSize = [GetNullableObjectAtIndex(list, 5) integerValue]; return pigeonResult; } + (nullable FGMPlatformTileOverlay *)nullableFromList:(NSArray *)list { @@ -428,7 +978,12 @@ + (nullable FGMPlatformTileOverlay *)nullableFromList:(NSArray *)list { } - (NSArray *)toList { return @[ - self.json ?: [NSNull null], + self.tileOverlayId ?: [NSNull null], + @(self.fadeIn), + @(self.transparency), + @(self.zIndex), + @(self.visible), + @(self.tileSize), ]; } @end @@ -699,6 +1254,30 @@ + (nullable FGMPlatformPoint *)nullableFromList:(NSArray *)list { } @end +@implementation FGMPlatformSize ++ (instancetype)makeWithWidth:(double)width height:(double)height { + FGMPlatformSize *pigeonResult = [[FGMPlatformSize alloc] init]; + pigeonResult.width = width; + pigeonResult.height = height; + return pigeonResult; +} ++ (FGMPlatformSize *)fromList:(NSArray *)list { + FGMPlatformSize *pigeonResult = [[FGMPlatformSize alloc] init]; + pigeonResult.width = [GetNullableObjectAtIndex(list, 0) doubleValue]; + pigeonResult.height = [GetNullableObjectAtIndex(list, 1) doubleValue]; + return pigeonResult; +} ++ (nullable FGMPlatformSize *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformSize fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.width), + @(self.height), + ]; +} +@end + @implementation FGMPlatformTileLayer + (instancetype)makeWithVisible:(BOOL)visible fadeIn:(BOOL)fadeIn @@ -756,6 +1335,204 @@ + (nullable FGMPlatformZoomRange *)nullableFromList:(NSArray *)list { } @end +@implementation FGMPlatformBitmap ++ (instancetype)makeWithBitmap:(id)bitmap { + FGMPlatformBitmap *pigeonResult = [[FGMPlatformBitmap alloc] init]; + pigeonResult.bitmap = bitmap; + return pigeonResult; +} ++ (FGMPlatformBitmap *)fromList:(NSArray *)list { + FGMPlatformBitmap *pigeonResult = [[FGMPlatformBitmap alloc] init]; + pigeonResult.bitmap = GetNullableObjectAtIndex(list, 0); + return pigeonResult; +} ++ (nullable FGMPlatformBitmap *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmap fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.bitmap ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformBitmapDefaultMarker ++ (instancetype)makeWithHue:(nullable NSNumber *)hue { + FGMPlatformBitmapDefaultMarker *pigeonResult = [[FGMPlatformBitmapDefaultMarker alloc] init]; + pigeonResult.hue = hue; + return pigeonResult; +} ++ (FGMPlatformBitmapDefaultMarker *)fromList:(NSArray *)list { + FGMPlatformBitmapDefaultMarker *pigeonResult = [[FGMPlatformBitmapDefaultMarker alloc] init]; + pigeonResult.hue = GetNullableObjectAtIndex(list, 0); + return pigeonResult; +} ++ (nullable FGMPlatformBitmapDefaultMarker *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmapDefaultMarker fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.hue ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformBitmapBytes ++ (instancetype)makeWithByteData:(FlutterStandardTypedData *)byteData + size:(nullable FGMPlatformSize *)size { + FGMPlatformBitmapBytes *pigeonResult = [[FGMPlatformBitmapBytes alloc] init]; + pigeonResult.byteData = byteData; + pigeonResult.size = size; + return pigeonResult; +} ++ (FGMPlatformBitmapBytes *)fromList:(NSArray *)list { + FGMPlatformBitmapBytes *pigeonResult = [[FGMPlatformBitmapBytes alloc] init]; + pigeonResult.byteData = GetNullableObjectAtIndex(list, 0); + pigeonResult.size = GetNullableObjectAtIndex(list, 1); + return pigeonResult; +} ++ (nullable FGMPlatformBitmapBytes *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmapBytes fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.byteData ?: [NSNull null], + self.size ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformBitmapAsset ++ (instancetype)makeWithName:(NSString *)name pkg:(nullable NSString *)pkg { + FGMPlatformBitmapAsset *pigeonResult = [[FGMPlatformBitmapAsset alloc] init]; + pigeonResult.name = name; + pigeonResult.pkg = pkg; + return pigeonResult; +} ++ (FGMPlatformBitmapAsset *)fromList:(NSArray *)list { + FGMPlatformBitmapAsset *pigeonResult = [[FGMPlatformBitmapAsset alloc] init]; + pigeonResult.name = GetNullableObjectAtIndex(list, 0); + pigeonResult.pkg = GetNullableObjectAtIndex(list, 1); + return pigeonResult; +} ++ (nullable FGMPlatformBitmapAsset *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmapAsset fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.name ?: [NSNull null], + self.pkg ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformBitmapAssetImage ++ (instancetype)makeWithName:(NSString *)name + scale:(double)scale + size:(nullable FGMPlatformSize *)size { + FGMPlatformBitmapAssetImage *pigeonResult = [[FGMPlatformBitmapAssetImage alloc] init]; + pigeonResult.name = name; + pigeonResult.scale = scale; + pigeonResult.size = size; + return pigeonResult; +} ++ (FGMPlatformBitmapAssetImage *)fromList:(NSArray *)list { + FGMPlatformBitmapAssetImage *pigeonResult = [[FGMPlatformBitmapAssetImage alloc] init]; + pigeonResult.name = GetNullableObjectAtIndex(list, 0); + pigeonResult.scale = [GetNullableObjectAtIndex(list, 1) doubleValue]; + pigeonResult.size = GetNullableObjectAtIndex(list, 2); + return pigeonResult; +} ++ (nullable FGMPlatformBitmapAssetImage *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmapAssetImage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.name ?: [NSNull null], + @(self.scale), + self.size ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformBitmapAssetMap ++ (instancetype)makeWithAssetName:(NSString *)assetName + bitmapScaling:(FGMPlatformMapBitmapScaling)bitmapScaling + imagePixelRatio:(double)imagePixelRatio + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height { + FGMPlatformBitmapAssetMap *pigeonResult = [[FGMPlatformBitmapAssetMap alloc] init]; + pigeonResult.assetName = assetName; + pigeonResult.bitmapScaling = bitmapScaling; + pigeonResult.imagePixelRatio = imagePixelRatio; + pigeonResult.width = width; + pigeonResult.height = height; + return pigeonResult; +} ++ (FGMPlatformBitmapAssetMap *)fromList:(NSArray *)list { + FGMPlatformBitmapAssetMap *pigeonResult = [[FGMPlatformBitmapAssetMap alloc] init]; + pigeonResult.assetName = GetNullableObjectAtIndex(list, 0); + FGMPlatformMapBitmapScalingBox *boxedFGMPlatformMapBitmapScaling = + GetNullableObjectAtIndex(list, 1); + pigeonResult.bitmapScaling = boxedFGMPlatformMapBitmapScaling.value; + pigeonResult.imagePixelRatio = [GetNullableObjectAtIndex(list, 2) doubleValue]; + pigeonResult.width = GetNullableObjectAtIndex(list, 3); + pigeonResult.height = GetNullableObjectAtIndex(list, 4); + return pigeonResult; +} ++ (nullable FGMPlatformBitmapAssetMap *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmapAssetMap fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.assetName ?: [NSNull null], + [[FGMPlatformMapBitmapScalingBox alloc] initWithValue:self.bitmapScaling], + @(self.imagePixelRatio), + self.width ?: [NSNull null], + self.height ?: [NSNull null], + ]; +} +@end + +@implementation FGMPlatformBitmapBytesMap ++ (instancetype)makeWithByteData:(FlutterStandardTypedData *)byteData + bitmapScaling:(FGMPlatformMapBitmapScaling)bitmapScaling + imagePixelRatio:(double)imagePixelRatio + width:(nullable NSNumber *)width + height:(nullable NSNumber *)height { + FGMPlatformBitmapBytesMap *pigeonResult = [[FGMPlatformBitmapBytesMap alloc] init]; + pigeonResult.byteData = byteData; + pigeonResult.bitmapScaling = bitmapScaling; + pigeonResult.imagePixelRatio = imagePixelRatio; + pigeonResult.width = width; + pigeonResult.height = height; + return pigeonResult; +} ++ (FGMPlatformBitmapBytesMap *)fromList:(NSArray *)list { + FGMPlatformBitmapBytesMap *pigeonResult = [[FGMPlatformBitmapBytesMap alloc] init]; + pigeonResult.byteData = GetNullableObjectAtIndex(list, 0); + FGMPlatformMapBitmapScalingBox *boxedFGMPlatformMapBitmapScaling = + GetNullableObjectAtIndex(list, 1); + pigeonResult.bitmapScaling = boxedFGMPlatformMapBitmapScaling.value; + pigeonResult.imagePixelRatio = [GetNullableObjectAtIndex(list, 2) doubleValue]; + pigeonResult.width = GetNullableObjectAtIndex(list, 3); + pigeonResult.height = GetNullableObjectAtIndex(list, 4); + return pigeonResult; +} ++ (nullable FGMPlatformBitmapBytesMap *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformBitmapBytesMap fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.byteData ?: [NSNull null], + [[FGMPlatformMapBitmapScalingBox alloc] initWithValue:self.bitmapScaling], + @(self.imagePixelRatio), + self.width ?: [NSNull null], + self.height ?: [NSNull null], + ]; +} +@end + @interface FGMMessagesPigeonCodecReader : FlutterStandardReader @end @implementation FGMMessagesPigeonCodecReader @@ -767,46 +1544,100 @@ - (nullable id)readValueOfType:(UInt8)type { ? nil : [[FGMPlatformMapTypeBox alloc] initWithValue:[enumAsNumber integerValue]]; } - case 130: + case 130: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil + ? nil + : [[FGMPlatformJointTypeBox alloc] initWithValue:[enumAsNumber integerValue]]; + } + case 131: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil ? nil + : [[FGMPlatformPatternItemTypeBox alloc] + initWithValue:[enumAsNumber integerValue]]; + } + case 132: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil ? nil + : [[FGMPlatformMapBitmapScalingBox alloc] + initWithValue:[enumAsNumber integerValue]]; + } + case 133: return [FGMPlatformCameraPosition fromList:[self readValue]]; - case 131: + case 134: return [FGMPlatformCameraUpdate fromList:[self readValue]]; - case 132: + case 135: + return [FGMPlatformCameraUpdateNewCameraPosition fromList:[self readValue]]; + case 136: + return [FGMPlatformCameraUpdateNewLatLng fromList:[self readValue]]; + case 137: + return [FGMPlatformCameraUpdateNewLatLngBounds fromList:[self readValue]]; + case 138: + return [FGMPlatformCameraUpdateNewLatLngZoom fromList:[self readValue]]; + case 139: + return [FGMPlatformCameraUpdateScrollBy fromList:[self readValue]]; + case 140: + return [FGMPlatformCameraUpdateZoomBy fromList:[self readValue]]; + case 141: + return [FGMPlatformCameraUpdateZoom fromList:[self readValue]]; + case 142: + return [FGMPlatformCameraUpdateZoomTo fromList:[self readValue]]; + case 143: return [FGMPlatformCircle fromList:[self readValue]]; - case 133: + case 144: return [FGMPlatformHeatmap fromList:[self readValue]]; - case 134: + case 145: + return [FGMPlatformInfoWindow fromList:[self readValue]]; + case 146: return [FGMPlatformCluster fromList:[self readValue]]; - case 135: + case 147: return [FGMPlatformClusterManager fromList:[self readValue]]; - case 136: + case 148: return [FGMPlatformMarker fromList:[self readValue]]; - case 137: + case 149: return [FGMPlatformPolygon fromList:[self readValue]]; - case 138: + case 150: return [FGMPlatformPolyline fromList:[self readValue]]; - case 139: + case 151: + return [FGMPlatformPatternItem fromList:[self readValue]]; + case 152: return [FGMPlatformTile fromList:[self readValue]]; - case 140: + case 153: return [FGMPlatformTileOverlay fromList:[self readValue]]; - case 141: + case 154: return [FGMPlatformEdgeInsets fromList:[self readValue]]; - case 142: + case 155: return [FGMPlatformLatLng fromList:[self readValue]]; - case 143: + case 156: return [FGMPlatformLatLngBounds fromList:[self readValue]]; - case 144: + case 157: return [FGMPlatformCameraTargetBounds fromList:[self readValue]]; - case 145: + case 158: return [FGMPlatformMapViewCreationParams fromList:[self readValue]]; - case 146: + case 159: return [FGMPlatformMapConfiguration fromList:[self readValue]]; - case 147: + case 160: return [FGMPlatformPoint fromList:[self readValue]]; - case 148: + case 161: + return [FGMPlatformSize fromList:[self readValue]]; + case 162: return [FGMPlatformTileLayer fromList:[self readValue]]; - case 149: + case 163: return [FGMPlatformZoomRange fromList:[self readValue]]; + case 164: + return [FGMPlatformBitmap fromList:[self readValue]]; + case 165: + return [FGMPlatformBitmapDefaultMarker fromList:[self readValue]]; + case 166: + return [FGMPlatformBitmapBytes fromList:[self readValue]]; + case 167: + return [FGMPlatformBitmapAsset fromList:[self readValue]]; + case 168: + return [FGMPlatformBitmapAssetImage fromList:[self readValue]]; + case 169: + return [FGMPlatformBitmapAssetMap fromList:[self readValue]]; + case 170: + return [FGMPlatformBitmapBytesMap fromList:[self readValue]]; default: return [super readValueOfType:type]; } @@ -821,65 +1652,131 @@ - (void)writeValue:(id)value { FGMPlatformMapTypeBox *box = (FGMPlatformMapTypeBox *)value; [self writeByte:129]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; - } else if ([value isKindOfClass:[FGMPlatformCameraPosition class]]) { + } else if ([value isKindOfClass:[FGMPlatformJointTypeBox class]]) { + FGMPlatformJointTypeBox *box = (FGMPlatformJointTypeBox *)value; [self writeByte:130]; + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[FGMPlatformPatternItemTypeBox class]]) { + FGMPlatformPatternItemTypeBox *box = (FGMPlatformPatternItemTypeBox *)value; + [self writeByte:131]; + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[FGMPlatformMapBitmapScalingBox class]]) { + FGMPlatformMapBitmapScalingBox *box = (FGMPlatformMapBitmapScalingBox *)value; + [self writeByte:132]; + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[FGMPlatformCameraPosition class]]) { + [self writeByte:133]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformCameraUpdate class]]) { - [self writeByte:131]; + [self writeByte:134]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateNewCameraPosition class]]) { + [self writeByte:135]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateNewLatLng class]]) { + [self writeByte:136]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateNewLatLngBounds class]]) { + [self writeByte:137]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateNewLatLngZoom class]]) { + [self writeByte:138]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateScrollBy class]]) { + [self writeByte:139]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateZoomBy class]]) { + [self writeByte:140]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateZoom class]]) { + [self writeByte:141]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformCameraUpdateZoomTo class]]) { + [self writeByte:142]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformCircle class]]) { - [self writeByte:132]; + [self writeByte:143]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformHeatmap class]]) { - [self writeByte:133]; + [self writeByte:144]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformInfoWindow class]]) { + [self writeByte:145]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformCluster class]]) { - [self writeByte:134]; + [self writeByte:146]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformClusterManager class]]) { - [self writeByte:135]; + [self writeByte:147]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformMarker class]]) { - [self writeByte:136]; + [self writeByte:148]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformPolygon class]]) { - [self writeByte:137]; + [self writeByte:149]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformPolyline class]]) { - [self writeByte:138]; + [self writeByte:150]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformPatternItem class]]) { + [self writeByte:151]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformTile class]]) { - [self writeByte:139]; + [self writeByte:152]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformTileOverlay class]]) { - [self writeByte:140]; + [self writeByte:153]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformEdgeInsets class]]) { - [self writeByte:141]; + [self writeByte:154]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformLatLng class]]) { - [self writeByte:142]; + [self writeByte:155]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformLatLngBounds class]]) { - [self writeByte:143]; + [self writeByte:156]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformCameraTargetBounds class]]) { - [self writeByte:144]; + [self writeByte:157]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformMapViewCreationParams class]]) { - [self writeByte:145]; + [self writeByte:158]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformMapConfiguration class]]) { - [self writeByte:146]; + [self writeByte:159]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformPoint class]]) { - [self writeByte:147]; + [self writeByte:160]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformSize class]]) { + [self writeByte:161]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformTileLayer class]]) { - [self writeByte:148]; + [self writeByte:162]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FGMPlatformZoomRange class]]) { - [self writeByte:149]; + [self writeByte:163]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmap class]]) { + [self writeByte:164]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapDefaultMarker class]]) { + [self writeByte:165]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapBytes class]]) { + [self writeByte:166]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapAsset class]]) { + [self writeByte:167]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapAssetImage class]]) { + [self writeByte:168]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapAssetMap class]]) { + [self writeByte:169]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapBytesMap class]]) { + [self writeByte:170]; [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 9af2e061bde1..ba56b6170fde 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 @@ -348,7 +348,7 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId) - .animateCamera(PlatformCameraUpdate(json: cameraUpdate.toJson())); + .animateCamera(_platformCameraUpdateFromCameraUpdate(cameraUpdate)); } @override @@ -357,7 +357,7 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId) - .moveCamera(PlatformCameraUpdate(json: cameraUpdate.toJson())); + .moveCamera(_platformCameraUpdateFromCameraUpdate(cameraUpdate)); } @override @@ -565,12 +565,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { /// Converts a Pigeon [PlatformCluster] to the corresponding [Cluster]. static Cluster clusterFromPlatformCluster(PlatformCluster cluster) { - return Cluster( - ClusterManagerId(cluster.clusterManagerId), - cluster.markerIds - // See comment in messages.dart for why the force unwrap is okay. - .map((String? markerId) => MarkerId(markerId!)) - .toList(), + return Cluster(ClusterManagerId(cluster.clusterManagerId), + cluster.markerIds.map((String markerId) => MarkerId(markerId)).toList(), position: _latLngFromPlatformLatLng(cluster.position), bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds)); } @@ -586,29 +582,108 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { x: coordinate.x.toDouble(), y: coordinate.y.toDouble()); } + static PlatformPoint _platformPointFromOffset(Offset offset) { + return PlatformPoint(x: offset.dx, y: offset.dy); + } + + static PlatformSize _platformSizeFromSize(Size size) { + return PlatformSize(width: size.width, height: size.height); + } + static PlatformCircle _platformCircleFromCircle(Circle circle) { - return PlatformCircle(json: circle.toJson()); + return PlatformCircle( + consumeTapEvents: circle.consumeTapEvents, + fillColor: circle.fillColor.value, + strokeColor: circle.strokeColor.value, + visible: circle.visible, + strokeWidth: circle.strokeWidth, + zIndex: circle.zIndex.toDouble(), + center: _platformLatLngFromLatLng(circle.center), + radius: circle.radius, + circleId: circle.circleId.value, + ); } static PlatformHeatmap _platformHeatmapFromHeatmap(Heatmap heatmap) { return PlatformHeatmap(json: serializeHeatmap(heatmap)); } + static PlatformInfoWindow _platformInfoWindowFromInfoWindow( + InfoWindow window) { + return PlatformInfoWindow( + title: window.title, + snippet: window.snippet, + anchor: _platformPointFromOffset(window.anchor)); + } + static PlatformMarker _platformMarkerFromMarker(Marker marker) { - return PlatformMarker(json: marker.toJson()); + return PlatformMarker( + alpha: marker.alpha, + anchor: _platformPointFromOffset(marker.anchor), + consumeTapEvents: marker.consumeTapEvents, + draggable: marker.draggable, + flat: marker.flat, + icon: platformBitmapFromBitmapDescriptor(marker.icon), + infoWindow: _platformInfoWindowFromInfoWindow(marker.infoWindow), + position: _platformLatLngFromLatLng(marker.position), + rotation: marker.rotation, + visible: marker.visible, + zIndex: marker.zIndex, + markerId: marker.markerId.value, + clusterManagerId: marker.clusterManagerId?.value, + ); } static PlatformPolygon _platformPolygonFromPolygon(Polygon polygon) { - return PlatformPolygon(json: polygon.toJson()); + final List points = + polygon.points.map(_platformLatLngFromLatLng).toList(); + final List> holes = + polygon.holes.map((List hole) { + return hole.map(_platformLatLngFromLatLng).toList(); + }).toList(); + return PlatformPolygon( + polygonId: polygon.polygonId.value, + fillColor: polygon.fillColor.value, + geodesic: polygon.geodesic, + consumesTapEvents: polygon.consumeTapEvents, + points: points, + holes: holes, + strokeColor: polygon.strokeColor.value, + strokeWidth: polygon.strokeWidth, + zIndex: polygon.zIndex, + visible: polygon.visible, + ); } static PlatformPolyline _platformPolylineFromPolyline(Polyline polyline) { - return PlatformPolyline(json: polyline.toJson()); + final List points = + polyline.points.map(_platformLatLngFromLatLng).toList(); + final List pattern = + polyline.patterns.map(platformPatternItemFromPatternItem).toList(); + return PlatformPolyline( + polylineId: polyline.polylineId.value, + consumesTapEvents: polyline.consumeTapEvents, + color: polyline.color.value, + geodesic: polyline.geodesic, + visible: polyline.visible, + width: polyline.width, + zIndex: polyline.zIndex, + points: points, + jointType: platformJointTypeFromJointType(polyline.jointType), + patterns: pattern, + ); } static PlatformTileOverlay _platformTileOverlayFromTileOverlay( TileOverlay tileOverlay) { - return PlatformTileOverlay(json: tileOverlay.toJson()); + return PlatformTileOverlay( + tileOverlayId: tileOverlay.tileOverlayId.value, + fadeIn: tileOverlay.fadeIn, + transparency: tileOverlay.transparency, + zIndex: tileOverlay.zIndex, + visible: tileOverlay.visible, + tileSize: tileOverlay.tileSize, + ); } static PlatformClusterManager _platformClusterManagerFromClusterManager( @@ -616,6 +691,127 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { return PlatformClusterManager( identifier: clusterManager.clusterManagerId.value); } + + static PlatformCameraUpdate _platformCameraUpdateFromCameraUpdate( + CameraUpdate update) { + switch (update.updateType) { + case CameraUpdateType.newCameraPosition: + update as CameraUpdateNewCameraPosition; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateNewCameraPosition( + cameraPosition: _platformCameraPositionFromCameraPosition( + update.cameraPosition))); + case CameraUpdateType.newLatLng: + update as CameraUpdateNewLatLng; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateNewLatLng( + latLng: _platformLatLngFromLatLng(update.latLng))); + case CameraUpdateType.newLatLngZoom: + update as CameraUpdateNewLatLngZoom; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateNewLatLngZoom( + latLng: _platformLatLngFromLatLng(update.latLng), + zoom: update.zoom)); + case CameraUpdateType.newLatLngBounds: + update as CameraUpdateNewLatLngBounds; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateNewLatLngBounds( + bounds: _platformLatLngBoundsFromLatLngBounds(update.bounds)!, + padding: update.padding)); + case CameraUpdateType.zoomTo: + update as CameraUpdateZoomTo; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateZoomTo(zoom: update.zoom)); + case CameraUpdateType.zoomBy: + update as CameraUpdateZoomBy; + final Offset? focus = update.focus; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateZoomBy( + amount: update.amount, + focus: focus == null ? null : _platformPointFromOffset(focus))); + case CameraUpdateType.zoomIn: + update as CameraUpdateZoomIn; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateZoom(out: false)); + case CameraUpdateType.zoomOut: + update as CameraUpdateZoomOut; + return PlatformCameraUpdate( + cameraUpdate: PlatformCameraUpdateZoom(out: true)); + case CameraUpdateType.scrollBy: + update as CameraUpdateScrollBy; + return PlatformCameraUpdate( + cameraUpdate: + PlatformCameraUpdateScrollBy(dx: update.dx, dy: update.dy)); + } + } + + /// Converts [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. + @visibleForTesting + static PlatformMapBitmapScaling platformMapBitmapScalingFromScaling( + MapBitmapScaling scaling) { + switch (scaling) { + case MapBitmapScaling.auto: + return PlatformMapBitmapScaling.auto; + case MapBitmapScaling.none: + return PlatformMapBitmapScaling.none; + } + + // The enum comes from a different package, which could get a new value at + // any time, so provide a fallback that ensures this won't break when used + // with a version that contains new values. This is deliberately outside + // the switch rather than a `default` so that the linter will flag the + // switch as needing an update. + // ignore: dead_code + return PlatformMapBitmapScaling.auto; + } + + /// Converts [BitmapDescriptor] from platform interface to [PlatformBitmap] pigeon. + @visibleForTesting + static PlatformBitmap platformBitmapFromBitmapDescriptor( + BitmapDescriptor bitmap) { + switch (bitmap) { + case final DefaultMarker marker: + return PlatformBitmap( + bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble())); + case final BytesBitmap bytes: + final Size? size = bytes.size; + return PlatformBitmap( + bitmap: PlatformBitmapBytes( + byteData: bytes.byteData, + size: (size == null) ? null : _platformSizeFromSize(size))); + case final AssetBitmap asset: + return PlatformBitmap( + bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package)); + case final AssetImageBitmap asset: + final Size? size = asset.size; + return PlatformBitmap( + bitmap: PlatformBitmapAssetImage( + name: asset.name, + scale: asset.scale, + size: (size == null) ? null : _platformSizeFromSize(size))); + case final AssetMapBitmap asset: + return PlatformBitmap( + bitmap: PlatformBitmapAssetMap( + assetName: asset.assetName, + bitmapScaling: + platformMapBitmapScalingFromScaling(asset.bitmapScaling), + imagePixelRatio: asset.imagePixelRatio, + width: asset.width, + height: asset.height)); + case final BytesMapBitmap bytes: + return PlatformBitmap( + bitmap: PlatformBitmapBytesMap( + byteData: bytes.byteData, + bitmapScaling: + platformMapBitmapScalingFromScaling(bytes.bitmapScaling), + imagePixelRatio: bytes.imagePixelRatio, + width: bytes.width, + height: bytes.height)); + default: + throw ArgumentError( + 'Unrecognized type of bitmap ${bitmap.runtimeType}', 'bitmap'); + } + } } /// Callback handler for map events from the platform host. @@ -952,6 +1148,52 @@ PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson( return PlatformZoomRange(min: minMaxZoom[0], max: minMaxZoom[1]); } +/// Converts platform interface's JointType to Pigeon's PlatformJointType. +@visibleForTesting +PlatformJointType platformJointTypeFromJointType(JointType jointType) { + switch (jointType) { + case JointType.mitered: + return PlatformJointType.mitered; + case JointType.bevel: + return PlatformJointType.bevel; + case JointType.round: + return PlatformJointType.round; + } + // The enum comes from a different package, which could get a new value at + // any time, so provide a fallback that ensures this won't break when used + // with a version that contains new values. This is deliberately outside + // the switch rather than a `default` so that the linter will flag the + // switch as needing an update. + // ignore: dead_code + return PlatformJointType.mitered; +} + +/// Converts a PatternItem to Pigeon's PlatformPatternItem for PlatformPolyline +/// pattern member. +@visibleForTesting +PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) { + switch (item.type) { + case PatternItemType.dot: + return PlatformPatternItem(type: PlatformPatternItemType.dot); + case PatternItemType.dash: + final double length = (item as VariableLengthPatternItem).length; + return PlatformPatternItem( + type: PlatformPatternItemType.dash, length: length); + case PatternItemType.gap: + final double length = (item as VariableLengthPatternItem).length; + return PlatformPatternItem( + type: PlatformPatternItemType.gap, length: length); + } + + // The enum comes from a different package, which could get a new value at + // any time, so provide a fallback that ensures this won't break when used + // with a version that contains new values. This is deliberately outside + // the switch rather than a `default` so that the linter will flag the + // switch as needing an update. + // ignore: dead_code + return PlatformPatternItem(type: PlatformPatternItemType.dot); +} + /// Update specification for a set of [TileOverlay]s. // TODO(stuartmorgan): Fix the missing export of this class in the platform // interface, and remove this copy. 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 699d9e4e44af..30a3e4e138df 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.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.1), 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 @@ -38,6 +38,26 @@ enum PlatformMapType { hybrid, } +/// Join types for polyline joints. +enum PlatformJointType { + mitered, + bevel, + round, +} + +/// Enumeration of possible types for PatternItem. +enum PlatformPatternItemType { + dot, + dash, + gap, +} + +/// Pigeon equivalent of [MapBitmapScaling]. +enum PlatformMapBitmapScaling { + auto, + none, +} + /// Pigeon representatation of a CameraPosition. class PlatformCameraPosition { PlatformCameraPosition({ @@ -78,24 +98,221 @@ class PlatformCameraPosition { /// Pigeon representation of a CameraUpdate. class PlatformCameraUpdate { PlatformCameraUpdate({ - required this.json, + required this.cameraUpdate, }); - /// The update data, as JSON. This should only be set from - /// CameraUpdate.toJson, and the native code must interpret it according to the - /// internal implementation details of the CameraUpdate class. - Object json; + /// This Object must be one of the classes below prefixed with + /// PlatformCameraUpdate. Each such class represents a different type of + /// camera update, and each holds a different set of data, preventing the + /// use of a single unified class. + Object cameraUpdate; Object encode() { return [ - json, + cameraUpdate, ]; } static PlatformCameraUpdate decode(Object result) { result as List; return PlatformCameraUpdate( - json: result[0]!, + cameraUpdate: result[0]!, + ); + } +} + +/// Pigeon equivalent of NewCameraPosition +class PlatformCameraUpdateNewCameraPosition { + PlatformCameraUpdateNewCameraPosition({ + required this.cameraPosition, + }); + + PlatformCameraPosition cameraPosition; + + Object encode() { + return [ + cameraPosition, + ]; + } + + static PlatformCameraUpdateNewCameraPosition decode(Object result) { + result as List; + return PlatformCameraUpdateNewCameraPosition( + cameraPosition: result[0]! as PlatformCameraPosition, + ); + } +} + +/// Pigeon equivalent of NewLatLng +class PlatformCameraUpdateNewLatLng { + PlatformCameraUpdateNewLatLng({ + required this.latLng, + }); + + PlatformLatLng latLng; + + Object encode() { + return [ + latLng, + ]; + } + + static PlatformCameraUpdateNewLatLng decode(Object result) { + result as List; + return PlatformCameraUpdateNewLatLng( + latLng: result[0]! as PlatformLatLng, + ); + } +} + +/// Pigeon equivalent of NewLatLngBounds +class PlatformCameraUpdateNewLatLngBounds { + PlatformCameraUpdateNewLatLngBounds({ + required this.bounds, + required this.padding, + }); + + PlatformLatLngBounds bounds; + + double padding; + + Object encode() { + return [ + bounds, + padding, + ]; + } + + static PlatformCameraUpdateNewLatLngBounds decode(Object result) { + result as List; + return PlatformCameraUpdateNewLatLngBounds( + bounds: result[0]! as PlatformLatLngBounds, + padding: result[1]! as double, + ); + } +} + +/// Pigeon equivalent of NewLatLngZoom +class PlatformCameraUpdateNewLatLngZoom { + PlatformCameraUpdateNewLatLngZoom({ + required this.latLng, + required this.zoom, + }); + + PlatformLatLng latLng; + + double zoom; + + Object encode() { + return [ + latLng, + zoom, + ]; + } + + static PlatformCameraUpdateNewLatLngZoom decode(Object result) { + result as List; + return PlatformCameraUpdateNewLatLngZoom( + latLng: result[0]! as PlatformLatLng, + zoom: result[1]! as double, + ); + } +} + +/// Pigeon equivalent of ScrollBy +class PlatformCameraUpdateScrollBy { + PlatformCameraUpdateScrollBy({ + required this.dx, + required this.dy, + }); + + double dx; + + double dy; + + Object encode() { + return [ + dx, + dy, + ]; + } + + static PlatformCameraUpdateScrollBy decode(Object result) { + result as List; + return PlatformCameraUpdateScrollBy( + dx: result[0]! as double, + dy: result[1]! as double, + ); + } +} + +/// Pigeon equivalent of ZoomBy +class PlatformCameraUpdateZoomBy { + PlatformCameraUpdateZoomBy({ + required this.amount, + this.focus, + }); + + double amount; + + PlatformPoint? focus; + + Object encode() { + return [ + amount, + focus, + ]; + } + + static PlatformCameraUpdateZoomBy decode(Object result) { + result as List; + return PlatformCameraUpdateZoomBy( + amount: result[0]! as double, + focus: result[1] as PlatformPoint?, + ); + } +} + +/// Pigeon equivalent of ZoomIn/ZoomOut +class PlatformCameraUpdateZoom { + PlatformCameraUpdateZoom({ + required this.out, + }); + + bool out; + + Object encode() { + return [ + out, + ]; + } + + static PlatformCameraUpdateZoom decode(Object result) { + result as List; + return PlatformCameraUpdateZoom( + out: result[0]! as bool, + ); + } +} + +/// Pigeon equivalent of ZoomTo +class PlatformCameraUpdateZoomTo { + PlatformCameraUpdateZoomTo({ + required this.zoom, + }); + + double zoom; + + Object encode() { + return [ + zoom, + ]; + } + + static PlatformCameraUpdateZoomTo decode(Object result) { + result as List; + return PlatformCameraUpdateZoomTo( + zoom: result[0]! as double, ); } } @@ -103,24 +320,61 @@ class PlatformCameraUpdate { /// Pigeon equivalent of the Circle class. class PlatformCircle { PlatformCircle({ - required this.json, + this.consumeTapEvents = false, + this.fillColor = 0x00000000, + this.strokeColor = 0xFF000000, + this.visible = true, + this.strokeWidth = 10, + this.zIndex = 0.0, + required this.center, + this.radius = 0, + required this.circleId, }); - /// The circle data, as JSON. This should only be set from - /// Circle.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - Object json; + bool consumeTapEvents; + + int fillColor; + + int strokeColor; + + bool visible; + + int strokeWidth; + + double zIndex; + + PlatformLatLng center; + + double radius; + + String circleId; Object encode() { return [ - json, + consumeTapEvents, + fillColor, + strokeColor, + visible, + strokeWidth, + zIndex, + center, + radius, + circleId, ]; } static PlatformCircle decode(Object result) { result as List; return PlatformCircle( - json: result[0]!, + consumeTapEvents: result[0]! as bool, + fillColor: result[1]! as int, + strokeColor: result[2]! as int, + visible: result[3]! as bool, + strokeWidth: result[4]! as int, + zIndex: result[5]! as double, + center: result[6]! as PlatformLatLng, + radius: result[7]! as double, + circleId: result[8]! as String, ); } } @@ -150,6 +404,38 @@ class PlatformHeatmap { } } +/// Pigeon equivalent of the InfoWindow class. +class PlatformInfoWindow { + PlatformInfoWindow({ + this.title, + this.snippet, + required this.anchor, + }); + + String? title; + + String? snippet; + + PlatformPoint anchor; + + Object encode() { + return [ + title, + snippet, + anchor, + ]; + } + + static PlatformInfoWindow decode(Object result) { + result as List; + return PlatformInfoWindow( + title: result[0] as String?, + snippet: result[1] as String?, + anchor: result[2]! as PlatformPoint, + ); + } +} + /// Pigeon equivalent of Cluster. class PlatformCluster { PlatformCluster({ @@ -212,24 +498,81 @@ class PlatformClusterManager { /// Pigeon equivalent of the Marker class. class PlatformMarker { PlatformMarker({ - required this.json, + this.alpha = 1.0, + required this.anchor, + this.consumeTapEvents = false, + this.draggable = false, + this.flat = false, + required this.icon, + required this.infoWindow, + required this.position, + this.rotation = 0.0, + this.visible = true, + this.zIndex = 0.0, + required this.markerId, + this.clusterManagerId, }); - /// The marker data, as JSON. This should only be set from - /// Marker.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - Object json; + double alpha; + + PlatformPoint anchor; + + bool consumeTapEvents; + + bool draggable; + + bool flat; + + PlatformBitmap icon; + + PlatformInfoWindow infoWindow; + + PlatformLatLng position; + + double rotation; + + bool visible; + + double zIndex; + + String markerId; + + String? clusterManagerId; Object encode() { return [ - json, + alpha, + anchor, + consumeTapEvents, + draggable, + flat, + icon, + infoWindow, + position, + rotation, + visible, + zIndex, + markerId, + clusterManagerId, ]; } static PlatformMarker decode(Object result) { result as List; return PlatformMarker( - json: result[0]!, + alpha: result[0]! as double, + anchor: result[1]! as PlatformPoint, + consumeTapEvents: result[2]! as bool, + draggable: result[3]! as bool, + flat: result[4]! as bool, + icon: result[5]! as PlatformBitmap, + infoWindow: result[6]! as PlatformInfoWindow, + position: result[7]! as PlatformLatLng, + rotation: result[8]! as double, + visible: result[9]! as bool, + zIndex: result[10]! as double, + markerId: result[11]! as String, + clusterManagerId: result[12] as String?, ); } } @@ -237,24 +580,66 @@ class PlatformMarker { /// Pigeon equivalent of the Polygon class. class PlatformPolygon { PlatformPolygon({ - required this.json, + required this.polygonId, + required this.consumesTapEvents, + required this.fillColor, + required this.geodesic, + required this.points, + required this.holes, + required this.visible, + required this.strokeColor, + required this.strokeWidth, + required this.zIndex, }); - /// The polygon data, as JSON. This should only be set from - /// Polygon.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - Object json; + String polygonId; + + bool consumesTapEvents; + + int fillColor; + + bool geodesic; + + List points; + + List> holes; + + bool visible; + + int strokeColor; + + int strokeWidth; + + int zIndex; Object encode() { return [ - json, + polygonId, + consumesTapEvents, + fillColor, + geodesic, + points, + holes, + visible, + strokeColor, + strokeWidth, + zIndex, ]; } static PlatformPolygon decode(Object result) { result as List; return PlatformPolygon( - json: result[0]!, + polygonId: result[0]! as String, + consumesTapEvents: result[1]! as bool, + fillColor: result[2]! as int, + geodesic: result[3]! as bool, + points: (result[4] as List?)!.cast(), + holes: (result[5] as List?)!.cast>(), + visible: result[6]! as bool, + strokeColor: result[7]! as int, + strokeWidth: result[8]! as int, + zIndex: result[9]! as int, ); } } @@ -262,24 +647,95 @@ class PlatformPolygon { /// Pigeon equivalent of the Polyline class. class PlatformPolyline { PlatformPolyline({ - required this.json, + required this.polylineId, + required this.consumesTapEvents, + required this.color, + required this.geodesic, + required this.jointType, + required this.patterns, + required this.points, + required this.visible, + required this.width, + required this.zIndex, }); - /// The polyline data, as JSON. This should only be set from - /// Polyline.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - Object json; + String polylineId; + + bool consumesTapEvents; + + int color; + + bool geodesic; + + /// The joint type. + PlatformJointType jointType; + + /// The pattern data, as a list of pattern items. + List patterns; + + List points; + + bool visible; + + int width; + + int zIndex; Object encode() { return [ - json, + polylineId, + consumesTapEvents, + color, + geodesic, + jointType, + patterns, + points, + visible, + width, + zIndex, ]; } static PlatformPolyline decode(Object result) { result as List; return PlatformPolyline( - json: result[0]!, + polylineId: result[0]! as String, + consumesTapEvents: result[1]! as bool, + color: result[2]! as int, + geodesic: result[3]! as bool, + jointType: result[4]! as PlatformJointType, + patterns: (result[5] as List?)!.cast(), + points: (result[6] as List?)!.cast(), + visible: result[7]! as bool, + width: result[8]! as int, + zIndex: result[9]! as int, + ); + } +} + +/// Pigeon equivalent of the PatternItem class. +class PlatformPatternItem { + PlatformPatternItem({ + required this.type, + this.length, + }); + + PlatformPatternItemType type; + + double? length; + + Object encode() { + return [ + type, + length, + ]; + } + + static PlatformPatternItem decode(Object result) { + result as List; + return PlatformPatternItem( + type: result[0]! as PlatformPatternItemType, + length: result[1] as double?, ); } } @@ -319,24 +775,46 @@ class PlatformTile { /// Pigeon equivalent of the TileOverlay class. class PlatformTileOverlay { PlatformTileOverlay({ - required this.json, + required this.tileOverlayId, + required this.fadeIn, + required this.transparency, + required this.zIndex, + required this.visible, + required this.tileSize, }); - /// The tile overlay data, as JSON. This should only be set from - /// TileOverlay.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - Object json; + String tileOverlayId; + + bool fadeIn; + + double transparency; + + int zIndex; + + bool visible; + + int tileSize; Object encode() { return [ - json, + tileOverlayId, + fadeIn, + transparency, + zIndex, + visible, + tileSize, ]; } static PlatformTileOverlay decode(Object result) { result as List; return PlatformTileOverlay( - json: result[0]!, + tileOverlayId: result[0]! as String, + fadeIn: result[1]! as bool, + transparency: result[2]! as double, + zIndex: result[3]! as int, + visible: result[4]! as bool, + tileSize: result[5]! as int, ); } } @@ -650,6 +1128,33 @@ class PlatformPoint { } } +/// Pigeon representation of a size. +class PlatformSize { + PlatformSize({ + required this.width, + required this.height, + }); + + double width; + + double height; + + Object encode() { + return [ + width, + height, + ]; + } + + static PlatformSize decode(Object result) { + result as List; + return PlatformSize( + width: result[0]! as double, + height: result[1]! as double, + ); + } +} + /// Pigeon equivalent of GMSTileLayer properties. class PlatformTileLayer { PlatformTileLayer({ @@ -714,6 +1219,235 @@ class PlatformZoomRange { } } +/// Pigeon equivalent of [BitmapDescriptor]. As there are multiple disjoint +/// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which +/// may hold the pigeon equivalent type of any of them. +class PlatformBitmap { + PlatformBitmap({ + required this.bitmap, + }); + + /// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], + /// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], + /// [PlatformBitmapBytes], or [PlatformBitmapDefaultMarker]. + /// As Pigeon does not currently support data class inheritance, this + /// approach allows for the different bitmap implementations to be valid + /// argument and return types of the API methods. See + /// https://github.com/flutter/flutter/issues/117819. + Object bitmap; + + Object encode() { + return [ + bitmap, + ]; + } + + static PlatformBitmap decode(Object result) { + result as List; + return PlatformBitmap( + bitmap: result[0]!, + ); + } +} + +/// Pigeon equivalent of [DefaultMarker]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float) +class PlatformBitmapDefaultMarker { + PlatformBitmapDefaultMarker({ + this.hue, + }); + + double? hue; + + Object encode() { + return [ + hue, + ]; + } + + static PlatformBitmapDefaultMarker decode(Object result) { + result as List; + return PlatformBitmapDefaultMarker( + hue: result[0] as double?, + ); + } +} + +/// Pigeon equivalent of [BytesBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap) +class PlatformBitmapBytes { + PlatformBitmapBytes({ + required this.byteData, + this.size, + }); + + Uint8List byteData; + + PlatformSize? size; + + Object encode() { + return [ + byteData, + size, + ]; + } + + static PlatformBitmapBytes decode(Object result) { + result as List; + return PlatformBitmapBytes( + byteData: result[0]! as Uint8List, + size: result[1] as PlatformSize?, + ); + } +} + +/// Pigeon equivalent of [AssetBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAsset { + PlatformBitmapAsset({ + required this.name, + this.pkg, + }); + + String name; + + String? pkg; + + Object encode() { + return [ + name, + pkg, + ]; + } + + static PlatformBitmapAsset decode(Object result) { + result as List; + return PlatformBitmapAsset( + name: result[0]! as String, + pkg: result[1] as String?, + ); + } +} + +/// Pigeon equivalent of [AssetImageBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAssetImage { + PlatformBitmapAssetImage({ + required this.name, + required this.scale, + this.size, + }); + + String name; + + double scale; + + PlatformSize? size; + + Object encode() { + return [ + name, + scale, + size, + ]; + } + + static PlatformBitmapAssetImage decode(Object result) { + result as List; + return PlatformBitmapAssetImage( + name: result[0]! as String, + scale: result[1]! as double, + size: result[2] as PlatformSize?, + ); + } +} + +/// Pigeon equivalent of [AssetMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAssetMap { + PlatformBitmapAssetMap({ + required this.assetName, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); + + String assetName; + + PlatformMapBitmapScaling bitmapScaling; + + double imagePixelRatio; + + double? width; + + double? height; + + Object encode() { + return [ + assetName, + bitmapScaling, + imagePixelRatio, + width, + height, + ]; + } + + static PlatformBitmapAssetMap decode(Object result) { + result as List; + return PlatformBitmapAssetMap( + assetName: result[0]! as String, + bitmapScaling: result[1]! as PlatformMapBitmapScaling, + imagePixelRatio: result[2]! as double, + width: result[3] as double?, + height: result[4] as double?, + ); + } +} + +/// Pigeon equivalent of [BytesMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image +class PlatformBitmapBytesMap { + PlatformBitmapBytesMap({ + required this.byteData, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); + + Uint8List byteData; + + PlatformMapBitmapScaling bitmapScaling; + + double imagePixelRatio; + + double? width; + + double? height; + + Object encode() { + return [ + byteData, + bitmapScaling, + imagePixelRatio, + width, + height, + ]; + } + + static PlatformBitmapBytesMap decode(Object result) { + result as List; + return PlatformBitmapBytesMap( + byteData: result[0]! as Uint8List, + bitmapScaling: result[1]! as PlatformMapBitmapScaling, + imagePixelRatio: result[2]! as double, + width: result[3] as double?, + height: result[4] as double?, + ); + } +} + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -724,65 +1458,128 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformMapType) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is PlatformCameraPosition) { + } else if (value is PlatformJointType) { buffer.putUint8(130); + writeValue(buffer, value.index); + } else if (value is PlatformPatternItemType) { + buffer.putUint8(131); + writeValue(buffer, value.index); + } else if (value is PlatformMapBitmapScaling) { + buffer.putUint8(132); + writeValue(buffer, value.index); + } else if (value is PlatformCameraPosition) { + buffer.putUint8(133); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdate) { - buffer.putUint8(131); + buffer.putUint8(134); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateNewCameraPosition) { + buffer.putUint8(135); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateNewLatLng) { + buffer.putUint8(136); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateNewLatLngBounds) { + buffer.putUint8(137); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateNewLatLngZoom) { + buffer.putUint8(138); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateScrollBy) { + buffer.putUint8(139); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateZoomBy) { + buffer.putUint8(140); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateZoom) { + buffer.putUint8(141); + writeValue(buffer, value.encode()); + } else if (value is PlatformCameraUpdateZoomTo) { + buffer.putUint8(142); writeValue(buffer, value.encode()); } else if (value is PlatformCircle) { - buffer.putUint8(132); + buffer.putUint8(143); writeValue(buffer, value.encode()); } else if (value is PlatformHeatmap) { - buffer.putUint8(133); + buffer.putUint8(144); + writeValue(buffer, value.encode()); + } else if (value is PlatformInfoWindow) { + buffer.putUint8(145); writeValue(buffer, value.encode()); } else if (value is PlatformCluster) { - buffer.putUint8(134); + buffer.putUint8(146); writeValue(buffer, value.encode()); } else if (value is PlatformClusterManager) { - buffer.putUint8(135); + buffer.putUint8(147); writeValue(buffer, value.encode()); } else if (value is PlatformMarker) { - buffer.putUint8(136); + buffer.putUint8(148); writeValue(buffer, value.encode()); } else if (value is PlatformPolygon) { - buffer.putUint8(137); + buffer.putUint8(149); writeValue(buffer, value.encode()); } else if (value is PlatformPolyline) { - buffer.putUint8(138); + buffer.putUint8(150); + writeValue(buffer, value.encode()); + } else if (value is PlatformPatternItem) { + buffer.putUint8(151); writeValue(buffer, value.encode()); } else if (value is PlatformTile) { - buffer.putUint8(139); + buffer.putUint8(152); writeValue(buffer, value.encode()); } else if (value is PlatformTileOverlay) { - buffer.putUint8(140); + buffer.putUint8(153); writeValue(buffer, value.encode()); } else if (value is PlatformEdgeInsets) { - buffer.putUint8(141); + buffer.putUint8(154); writeValue(buffer, value.encode()); } else if (value is PlatformLatLng) { - buffer.putUint8(142); + buffer.putUint8(155); writeValue(buffer, value.encode()); } else if (value is PlatformLatLngBounds) { - buffer.putUint8(143); + buffer.putUint8(156); writeValue(buffer, value.encode()); } else if (value is PlatformCameraTargetBounds) { - buffer.putUint8(144); + buffer.putUint8(157); writeValue(buffer, value.encode()); } else if (value is PlatformMapViewCreationParams) { - buffer.putUint8(145); + buffer.putUint8(158); writeValue(buffer, value.encode()); } else if (value is PlatformMapConfiguration) { - buffer.putUint8(146); + buffer.putUint8(159); writeValue(buffer, value.encode()); } else if (value is PlatformPoint) { - buffer.putUint8(147); + buffer.putUint8(160); + writeValue(buffer, value.encode()); + } else if (value is PlatformSize) { + buffer.putUint8(161); writeValue(buffer, value.encode()); } else if (value is PlatformTileLayer) { - buffer.putUint8(148); + buffer.putUint8(162); writeValue(buffer, value.encode()); } else if (value is PlatformZoomRange) { - buffer.putUint8(149); + buffer.putUint8(163); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmap) { + buffer.putUint8(164); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapDefaultMarker) { + buffer.putUint8(165); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapBytes) { + buffer.putUint8(166); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapAsset) { + buffer.putUint8(167); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapAssetImage) { + buffer.putUint8(168); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapAssetMap) { + buffer.putUint8(169); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapBytesMap) { + buffer.putUint8(170); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -796,45 +1593,90 @@ class _PigeonCodec extends StandardMessageCodec { final int? value = readValue(buffer) as int?; return value == null ? null : PlatformMapType.values[value]; case 130: - return PlatformCameraPosition.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null ? null : PlatformJointType.values[value]; case 131: - return PlatformCameraUpdate.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null ? null : PlatformPatternItemType.values[value]; case 132: - return PlatformCircle.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null ? null : PlatformMapBitmapScaling.values[value]; case 133: - return PlatformHeatmap.decode(readValue(buffer)!); + return PlatformCameraPosition.decode(readValue(buffer)!); case 134: - return PlatformCluster.decode(readValue(buffer)!); + return PlatformCameraUpdate.decode(readValue(buffer)!); case 135: - return PlatformClusterManager.decode(readValue(buffer)!); + return PlatformCameraUpdateNewCameraPosition.decode(readValue(buffer)!); case 136: - return PlatformMarker.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLng.decode(readValue(buffer)!); case 137: - return PlatformPolygon.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLngBounds.decode(readValue(buffer)!); case 138: - return PlatformPolyline.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLngZoom.decode(readValue(buffer)!); case 139: - return PlatformTile.decode(readValue(buffer)!); + return PlatformCameraUpdateScrollBy.decode(readValue(buffer)!); case 140: - return PlatformTileOverlay.decode(readValue(buffer)!); + return PlatformCameraUpdateZoomBy.decode(readValue(buffer)!); case 141: - return PlatformEdgeInsets.decode(readValue(buffer)!); + return PlatformCameraUpdateZoom.decode(readValue(buffer)!); case 142: - return PlatformLatLng.decode(readValue(buffer)!); + return PlatformCameraUpdateZoomTo.decode(readValue(buffer)!); case 143: - return PlatformLatLngBounds.decode(readValue(buffer)!); + return PlatformCircle.decode(readValue(buffer)!); case 144: - return PlatformCameraTargetBounds.decode(readValue(buffer)!); + return PlatformHeatmap.decode(readValue(buffer)!); case 145: - return PlatformMapViewCreationParams.decode(readValue(buffer)!); + return PlatformInfoWindow.decode(readValue(buffer)!); case 146: - return PlatformMapConfiguration.decode(readValue(buffer)!); + return PlatformCluster.decode(readValue(buffer)!); case 147: - return PlatformPoint.decode(readValue(buffer)!); + return PlatformClusterManager.decode(readValue(buffer)!); case 148: - return PlatformTileLayer.decode(readValue(buffer)!); + return PlatformMarker.decode(readValue(buffer)!); case 149: + return PlatformPolygon.decode(readValue(buffer)!); + case 150: + return PlatformPolyline.decode(readValue(buffer)!); + case 151: + return PlatformPatternItem.decode(readValue(buffer)!); + case 152: + return PlatformTile.decode(readValue(buffer)!); + case 153: + return PlatformTileOverlay.decode(readValue(buffer)!); + case 154: + return PlatformEdgeInsets.decode(readValue(buffer)!); + case 155: + return PlatformLatLng.decode(readValue(buffer)!); + case 156: + return PlatformLatLngBounds.decode(readValue(buffer)!); + case 157: + return PlatformCameraTargetBounds.decode(readValue(buffer)!); + case 158: + return PlatformMapViewCreationParams.decode(readValue(buffer)!); + case 159: + return PlatformMapConfiguration.decode(readValue(buffer)!); + case 160: + return PlatformPoint.decode(readValue(buffer)!); + case 161: + return PlatformSize.decode(readValue(buffer)!); + case 162: + return PlatformTileLayer.decode(readValue(buffer)!); + case 163: return PlatformZoomRange.decode(readValue(buffer)!); + case 164: + return PlatformBitmap.decode(readValue(buffer)!); + case 165: + return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); + case 166: + return PlatformBitmapBytes.decode(readValue(buffer)!); + case 167: + return PlatformBitmapAsset.decode(readValue(buffer)!); + case 168: + return PlatformBitmapAssetImage.decode(readValue(buffer)!); + case 169: + return PlatformBitmapAssetMap.decode(readValue(buffer)!); + case 170: + 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 8cc612c684c7..342bd9ea8019 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 @@ -38,29 +38,92 @@ class PlatformCameraPosition { /// Pigeon representation of a CameraUpdate. class PlatformCameraUpdate { - PlatformCameraUpdate(this.json); - - /// The update data, as JSON. This should only be set from - /// CameraUpdate.toJson, and the native code must interpret it according to the - /// internal implementation details of the CameraUpdate class. - // TODO(stuartmorgan): Update the google_maps_platform_interface CameraUpdate - // class to provide a structured representation of an update. Currently it - // uses JSON as its only state, so there is no way to preserve structure. - // This wrapper class exists as a placeholder for now to at least provide - // type safety in the top-level call's arguments. - final Object json; + PlatformCameraUpdate(this.cameraUpdate); + + /// This Object must be one of the classes below prefixed with + /// PlatformCameraUpdate. Each such class represents a different type of + /// camera update, and each holds a different set of data, preventing the + /// use of a single unified class. + // Pigeon does not support inheritance, which prevents a more strict type + // bound. See https://github.com/flutter/flutter/issues/117819. + final Object cameraUpdate; +} + +/// Pigeon equivalent of NewCameraPosition +class PlatformCameraUpdateNewCameraPosition { + PlatformCameraUpdateNewCameraPosition(this.cameraPosition); + final PlatformCameraPosition cameraPosition; +} + +/// Pigeon equivalent of NewLatLng +class PlatformCameraUpdateNewLatLng { + PlatformCameraUpdateNewLatLng(this.latLng); + final PlatformLatLng latLng; +} + +/// Pigeon equivalent of NewLatLngBounds +class PlatformCameraUpdateNewLatLngBounds { + PlatformCameraUpdateNewLatLngBounds(this.bounds, this.padding); + final PlatformLatLngBounds bounds; + final double padding; +} + +/// Pigeon equivalent of NewLatLngZoom +class PlatformCameraUpdateNewLatLngZoom { + PlatformCameraUpdateNewLatLngZoom(this.latLng, this.zoom); + final PlatformLatLng latLng; + final double zoom; +} + +/// Pigeon equivalent of ScrollBy +class PlatformCameraUpdateScrollBy { + PlatformCameraUpdateScrollBy(this.dx, this.dy); + final double dx; + final double dy; +} + +/// Pigeon equivalent of ZoomBy +class PlatformCameraUpdateZoomBy { + PlatformCameraUpdateZoomBy(this.amount, [this.focus]); + final double amount; + final PlatformPoint? focus; +} + +/// Pigeon equivalent of ZoomIn/ZoomOut +class PlatformCameraUpdateZoom { + PlatformCameraUpdateZoom(this.out); + final bool out; +} + +/// Pigeon equivalent of ZoomTo +class PlatformCameraUpdateZoomTo { + PlatformCameraUpdateZoomTo(this.zoom); + final double zoom; } /// Pigeon equivalent of the Circle class. class PlatformCircle { - PlatformCircle(this.json); + PlatformCircle({ + required this.circleId, + required this.center, + this.consumeTapEvents = false, + this.fillColor = 0x00000000, + this.strokeColor = 0xFF000000, + this.visible = true, + this.strokeWidth = 10, + this.zIndex = 0.0, + this.radius = 0, + }); - /// The circle data, as JSON. This should only be set from - /// Circle.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - // TODO(stuartmorgan): Replace this with structured data. This exists only to - // allow incremental migration to Pigeon. - final Object json; + final bool consumeTapEvents; + final int fillColor; + final int strokeColor; + final bool visible; + final int strokeWidth; + final double zIndex; + final PlatformLatLng center; + final double radius; + final String circleId; } /// Pigeon equivalent of the Heatmap class. @@ -75,6 +138,19 @@ class PlatformHeatmap { final Object json; } +/// Pigeon equivalent of the InfoWindow class. +class PlatformInfoWindow { + PlatformInfoWindow({ + required this.anchor, + this.title, + this.snippet, + }); + + final String? title; + final String? snippet; + final PlatformPoint anchor; +} + /// Pigeon equivalent of Cluster. class PlatformCluster { PlatformCluster({ @@ -99,38 +175,117 @@ class PlatformClusterManager { /// Pigeon equivalent of the Marker class. class PlatformMarker { - PlatformMarker(this.json); + PlatformMarker({ + required this.markerId, + required this.icon, + this.alpha = 1.0, + required this.anchor, + this.consumeTapEvents = false, + this.draggable = false, + this.flat = false, + required this.infoWindow, + required this.position, + this.rotation = 0.0, + this.visible = true, + this.zIndex = 0.0, + this.clusterManagerId, + }); - /// The marker data, as JSON. This should only be set from - /// Marker.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - // TODO(stuartmorgan): Replace this with structured data. This exists only to - // allow incremental migration to Pigeon. - final Object json; + final double alpha; + final PlatformPoint anchor; + final bool consumeTapEvents; + final bool draggable; + final bool flat; + + final PlatformBitmap icon; + final PlatformInfoWindow infoWindow; + final PlatformLatLng position; + final double rotation; + final bool visible; + final double zIndex; + final String markerId; + final String? clusterManagerId; } /// Pigeon equivalent of the Polygon class. class PlatformPolygon { - PlatformPolygon(this.json); + PlatformPolygon({ + required this.polygonId, + required this.consumesTapEvents, + required this.fillColor, + required this.geodesic, + required this.points, + required this.holes, + required this.visible, + required this.strokeColor, + required this.strokeWidth, + required this.zIndex, + }); - /// The polygon data, as JSON. This should only be set from - /// Polygon.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - // TODO(stuartmorgan): Replace this with structured data. This exists only to - // allow incremental migration to Pigeon. - final Object json; + final String polygonId; + final bool consumesTapEvents; + final int fillColor; + final bool geodesic; + final List points; + final List> holes; + final bool visible; + final int strokeColor; + final int strokeWidth; + final int zIndex; +} + +/// Join types for polyline joints. +enum PlatformJointType { + mitered, + bevel, + round, } /// Pigeon equivalent of the Polyline class. class PlatformPolyline { - PlatformPolyline(this.json); + PlatformPolyline({ + required this.polylineId, + required this.consumesTapEvents, + required this.color, + required this.geodesic, + required this.jointType, + required this.patterns, + required this.points, + required this.visible, + required this.width, + required this.zIndex, + }); - /// The polyline data, as JSON. This should only be set from - /// Polyline.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - // TODO(stuartmorgan): Replace this with structured data. This exists only to - // allow incremental migration to Pigeon. - final Object json; + final String polylineId; + final bool consumesTapEvents; + final int color; + final bool geodesic; + + /// The joint type. + final PlatformJointType jointType; + + /// The pattern data, as a list of pattern items. + final List patterns; + final List points; + + final bool visible; + final int width; + final int zIndex; +} + +/// Enumeration of possible types for PatternItem. +enum PlatformPatternItemType { + dot, + dash, + gap, +} + +/// Pigeon equivalent of the PatternItem class. +class PlatformPatternItem { + PlatformPatternItem({required this.type, this.length}); + + final PlatformPatternItemType type; + final double? length; } /// Pigeon equivalent of the Tile class. @@ -144,14 +299,21 @@ class PlatformTile { /// Pigeon equivalent of the TileOverlay class. class PlatformTileOverlay { - PlatformTileOverlay(this.json); + PlatformTileOverlay({ + required this.tileOverlayId, + required this.fadeIn, + required this.transparency, + required this.zIndex, + required this.visible, + required this.tileSize, + }); - /// The tile overlay data, as JSON. This should only be set from - /// TileOverlay.toJson, and the native code must interpret it according to the - /// internal implementation details of that method. - // TODO(stuartmorgan): Replace this with structured data. This exists only to - // allow incremental migration to Pigeon. - final Object json; + final String tileOverlayId; + final bool fadeIn; + final double transparency; + final int zIndex; + final bool visible; + final int tileSize; } /// Pigeon equivalent of Flutter's EdgeInsets. @@ -269,6 +431,14 @@ class PlatformPoint { final double y; } +/// Pigeon representation of a size. +class PlatformSize { + PlatformSize({required this.width, required this.height}); + + final double width; + final double height; +} + /// Pigeon equivalent of GMSTileLayer properties. class PlatformTileLayer { PlatformTileLayer({ @@ -292,6 +462,90 @@ class PlatformZoomRange { final double? max; } +/// Pigeon equivalent of [BitmapDescriptor]. As there are multiple disjoint +/// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which +/// may hold the pigeon equivalent type of any of them. +class PlatformBitmap { + PlatformBitmap({required this.bitmap}); + + /// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], + /// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], + /// [PlatformBitmapBytes], or [PlatformBitmapDefaultMarker]. + /// As Pigeon does not currently support data class inheritance, this + /// approach allows for the different bitmap implementations to be valid + /// argument and return types of the API methods. See + /// https://github.com/flutter/flutter/issues/117819. + final Object bitmap; +} + +/// Pigeon equivalent of [DefaultMarker]. +class PlatformBitmapDefaultMarker { + PlatformBitmapDefaultMarker({this.hue}); + + final double? hue; +} + +/// Pigeon equivalent of [BytesBitmap]. +class PlatformBitmapBytes { + PlatformBitmapBytes({required this.byteData, this.size}); + + final Uint8List byteData; + final PlatformSize? size; +} + +/// Pigeon equivalent of [AssetBitmap]. +class PlatformBitmapAsset { + PlatformBitmapAsset({required this.name, this.pkg}); + + final String name; + final String? pkg; +} + +/// Pigeon equivalent of [AssetImageBitmap]. +class PlatformBitmapAssetImage { + PlatformBitmapAssetImage( + {required this.name, required this.scale, this.size}); + final String name; + final double scale; + final PlatformSize? size; +} + +/// Pigeon equivalent of [AssetMapBitmap]. +class PlatformBitmapAssetMap { + PlatformBitmapAssetMap( + {required this.assetName, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height}); + final String assetName; + final PlatformMapBitmapScaling bitmapScaling; + final double imagePixelRatio; + final double? width; + final double? height; +} + +/// Pigeon equivalent of [BytesMapBitmap]. +class PlatformBitmapBytesMap { + PlatformBitmapBytesMap( + {required this.byteData, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height}); + final Uint8List byteData; + final PlatformMapBitmapScaling bitmapScaling; + final double imagePixelRatio; + final double? width; + final double? height; +} + +/// Pigeon equivalent of [MapBitmapScaling]. +enum PlatformMapBitmapScaling { + auto, + none, +} + /// Interface for non-test interactions with the native SDK. /// /// For test-only state queries, see [MapsInspectorApi]. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index 9d727a0c46fa..b90fc561e983 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.13.1 +version: 2.13.2 environment: sdk: ^3.3.0 @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - google_maps_flutter_platform_interface: ^2.9.0 + google_maps_flutter_platform_interface: ^2.9.5 stream_transform: ^2.0.0 dev_dependencies: diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart index 7a2f26809dd3..51a5e04cd975 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart @@ -104,7 +104,7 @@ void main() { expect(bounds, expectedBounds); }); - test('moveCamera calls through', () async { + test('moveCamera calls through with expected scrollBy', () async { const int mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap(mapId: mapId); @@ -115,10 +115,14 @@ void main() { final VerificationResult verification = verify(api.moveCamera(captureAny)); final PlatformCameraUpdate passedUpdate = verification.captured[0] as PlatformCameraUpdate; - expect(passedUpdate.json, update.toJson()); + final PlatformCameraUpdateScrollBy scroll = + passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + update as CameraUpdateScrollBy; + expect(scroll.dx, update.dx); + expect(scroll.dy, update.dy); }); - test('animateCamera calls through', () async { + test('animateCamera calls through with expected scrollBy', () async { const int mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap(mapId: mapId); @@ -130,7 +134,11 @@ void main() { verify(api.animateCamera(captureAny)); final PlatformCameraUpdate passedUpdate = verification.captured[0] as PlatformCameraUpdate; - expect(passedUpdate.json, update.toJson()); + final PlatformCameraUpdateScrollBy scroll = + passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + update as CameraUpdateScrollBy; + expect(scroll.dx, update.dx); + expect(scroll.dy, update.dy); }); test('getZoomLevel passes values correctly', () async { @@ -291,20 +299,73 @@ void main() { final VerificationResult verification = verify(api.updateCircles(captureAny, captureAny, captureAny)); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final List toAdd = + verification.captured[0] as List; + final List toChange = + verification.captured[1] as List; + final List toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.circleId.value); // Object two should be changed. - expect(toChange.length, 1); - expect(toChange.first?.json, object2new.toJson()); + { + expect(toChange.length, 1); + final PlatformCircle firstChanged = toChange.first; + expect(firstChanged.consumeTapEvents, object2new.consumeTapEvents); + expect(firstChanged.fillColor, object2new.fillColor.value); + expect(firstChanged.strokeColor, object2new.strokeColor.value); + expect(firstChanged.visible, object2new.visible); + expect(firstChanged.strokeWidth, object2new.strokeWidth); + expect(firstChanged.zIndex, object2new.zIndex.toDouble()); + expect(firstChanged.center.latitude, object2new.center.latitude); + expect(firstChanged.center.longitude, object2new.center.longitude); + expect(firstChanged.radius, object2new.radius); + expect(firstChanged.circleId, object2new.circleId.value); + } + // Object 3 should be added. + { + expect(toAdd.length, 1); + final PlatformCircle firstAdded = toAdd.first; + expect(firstAdded.consumeTapEvents, object3.consumeTapEvents); + expect(firstAdded.fillColor, object3.fillColor.value); + expect(firstAdded.strokeColor, object3.strokeColor.value); + expect(firstAdded.visible, object3.visible); + expect(firstAdded.strokeWidth, object3.strokeWidth); + expect(firstAdded.zIndex, object3.zIndex.toDouble()); + expect(firstAdded.center.latitude, object3.center.latitude); + expect(firstAdded.center.longitude, object3.center.longitude); + expect(firstAdded.radius, object3.radius); + expect(firstAdded.circleId, object3.circleId.value); + } + }); + + test('updateClusterManagers passes expected arguments', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + const ClusterManager object1 = + ClusterManager(clusterManagerId: ClusterManagerId('1')); + const ClusterManager object3 = + ClusterManager(clusterManagerId: ClusterManagerId('3')); + await maps.updateClusterManagers( + ClusterManagerUpdates.from( + {object1}, {object3}), + mapId: mapId); + + final VerificationResult verification = + verify(api.updateClusterManagers(captureAny, captureAny)); + final List toAdd = + verification.captured[0] as List; + final List toRemove = verification.captured[1] as List; + // Object one should be removed. + expect(toRemove.length, 1); + expect(toRemove.first, object1.clusterManagerId.value); + // Unlike other map object types, changes are not possible for cluster + // managers, since they have no non-ID properties. // Object 3 should be added. expect(toAdd.length, 1); - expect(toAdd.first?.json, object3.toJson()); + expect(toAdd.first.identifier, object3.clusterManagerId.value); }); test('updateMarkers passes expected arguments', () async { @@ -323,20 +384,69 @@ void main() { final VerificationResult verification = verify(api.updateMarkers(captureAny, captureAny, captureAny)); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final List toAdd = + verification.captured[0] as List; + final List toChange = + verification.captured[1] as List; + final List toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.markerId.value); // Object two should be changed. - expect(toChange.length, 1); - expect(toChange.first?.json, object2new.toJson()); + { + expect(toChange.length, 1); + final PlatformMarker firstChanged = toChange.first; + expect(firstChanged.alpha, object2new.alpha); + expect(firstChanged.anchor.x, object2new.anchor.dx); + expect(firstChanged.anchor.y, object2new.anchor.dy); + expect(firstChanged.consumeTapEvents, object2new.consumeTapEvents); + expect(firstChanged.draggable, object2new.draggable); + expect(firstChanged.flat, object2new.flat); + expect( + firstChanged.icon.bitmap.runtimeType, + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( + object2new.icon) + .bitmap + .runtimeType); + expect(firstChanged.infoWindow.title, object2new.infoWindow.title); + expect(firstChanged.infoWindow.snippet, object2new.infoWindow.snippet); + expect(firstChanged.infoWindow.anchor.x, object2new.infoWindow.anchor.dx); + expect(firstChanged.infoWindow.anchor.y, object2new.infoWindow.anchor.dy); + expect(firstChanged.position.latitude, object2new.position.latitude); + expect(firstChanged.position.longitude, object2new.position.longitude); + expect(firstChanged.rotation, object2new.rotation); + expect(firstChanged.visible, object2new.visible); + expect(firstChanged.zIndex, object2new.zIndex); + expect(firstChanged.markerId, object2new.markerId.value); + expect(firstChanged.clusterManagerId, object2new.clusterManagerId?.value); + } // Object 3 should be added. - expect(toAdd.length, 1); - expect(toAdd.first?.json, object3.toJson()); + { + expect(toAdd.length, 1); + final PlatformMarker firstAdded = toAdd.first; + expect(firstAdded.alpha, object3.alpha); + expect(firstAdded.anchor.x, object3.anchor.dx); + expect(firstAdded.anchor.y, object3.anchor.dy); + expect(firstAdded.consumeTapEvents, object3.consumeTapEvents); + expect(firstAdded.draggable, object3.draggable); + expect(firstAdded.flat, object3.flat); + expect( + firstAdded.icon.bitmap.runtimeType, + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(object3.icon) + .bitmap + .runtimeType); + expect(firstAdded.infoWindow.title, object3.infoWindow.title); + expect(firstAdded.infoWindow.snippet, object3.infoWindow.snippet); + expect(firstAdded.infoWindow.anchor.x, object3.infoWindow.anchor.dx); + expect(firstAdded.infoWindow.anchor.y, object3.infoWindow.anchor.dy); + expect(firstAdded.position.latitude, object3.position.latitude); + expect(firstAdded.position.longitude, object3.position.longitude); + expect(firstAdded.rotation, object3.rotation); + expect(firstAdded.visible, object3.visible); + expect(firstAdded.zIndex, object3.zIndex); + expect(firstAdded.markerId, object3.markerId.value); + expect(firstAdded.clusterManagerId, object3.clusterManagerId?.value); + } }); test('updatePolygons passes expected arguments', () async { @@ -355,20 +465,44 @@ void main() { final VerificationResult verification = verify(api.updatePolygons(captureAny, captureAny, captureAny)); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final List toAdd = + verification.captured[0] as List; + final List toChange = + verification.captured[1] as List; + final List toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.polygonId.value); + void expectPolygon(PlatformPolygon actual, Polygon expected) { + expect(actual.polygonId, expected.polygonId.value); + expect(actual.consumesTapEvents, expected.consumeTapEvents); + expect(actual.fillColor, expected.fillColor.value); + expect(actual.geodesic, expected.geodesic); + expect(actual.points.length, expected.points.length); + for (final (int i, PlatformLatLng? point) in actual.points.indexed) { + expect(point?.latitude, expected.points[i].latitude); + expect(point?.longitude, expected.points[i].longitude); + } + expect(actual.holes.length, expected.holes.length); + for (final (int i, List? hole) in actual.holes.indexed) { + final List expectedHole = expected.holes[i]; + for (final (int j, PlatformLatLng? point) in hole!.indexed) { + expect(point?.latitude, expectedHole[j].latitude); + expect(point?.longitude, expectedHole[j].longitude); + } + } + expect(actual.visible, expected.visible); + expect(actual.strokeColor, expected.strokeColor.value); + expect(actual.strokeWidth, expected.strokeWidth); + expect(actual.zIndex, expected.zIndex); + } + // Object two should be changed. expect(toChange.length, 1); - expect(toChange.first?.json, object2new.toJson()); + expectPolygon(toChange.first, object2new); // Object 3 should be added. expect(toAdd.length, 1); - expect(toAdd.first?.json, object3.toJson()); + expectPolygon(toAdd.first, object3); }); test('updatePolylines passes expected arguments', () async { @@ -378,8 +512,14 @@ void main() { const Polyline object1 = Polyline(polylineId: PolylineId('1')); const Polyline object2old = Polyline(polylineId: PolylineId('2')); - final Polyline object2new = object2old.copyWith(widthParam: 42); - const Polyline object3 = Polyline(polylineId: PolylineId('3')); + final Polyline object2new = object2old.copyWith( + widthParam: 42, startCapParam: Cap.squareCap, endCapParam: Cap.buttCap); + final Cap customCap = + Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker, refWidth: 15); + final Polyline object3 = Polyline( + polylineId: const PolylineId('3'), + startCap: customCap, + endCap: Cap.roundCap); await maps.updatePolylines( PolylineUpdates.from( {object1, object2old}, {object2new, object3}), @@ -387,20 +527,43 @@ void main() { final VerificationResult verification = verify(api.updatePolylines(captureAny, captureAny, captureAny)); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final List toAdd = + verification.captured[0] as List; + final List toChange = + verification.captured[1] as List; + final List toRemove = verification.captured[2] as List; + void expectPolyline(PlatformPolyline actual, Polyline expected) { + expect(actual.polylineId, expected.polylineId.value); + expect(actual.consumesTapEvents, expected.consumeTapEvents); + expect(actual.color, expected.color.value); + expect(actual.geodesic, expected.geodesic); + expect( + actual.jointType, platformJointTypeFromJointType(expected.jointType)); + expect(actual.visible, expected.visible); + expect(actual.width, expected.width); + expect(actual.zIndex, expected.zIndex); + expect(actual.points.length, expected.points.length); + for (final (int i, PlatformLatLng? point) in actual.points.indexed) { + expect(point?.latitude, actual.points[i].latitude); + expect(point?.longitude, actual.points[i].longitude); + } + expect(actual.patterns.length, expected.patterns.length); + for (final (int i, PlatformPatternItem? pattern) + in actual.patterns.indexed) { + expect(pattern?.encode(), + platformPatternItemFromPatternItem(expected.patterns[i]).encode()); + } + } + // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.polylineId.value); // Object two should be changed. expect(toChange.length, 1); - expect(toChange.first?.json, object2new.toJson()); + expectPolyline(toChange.first, object2new); // Object 3 should be added. expect(toAdd.length, 1); - expect(toAdd.first?.json, object3.toJson()); + expectPolyline(toAdd.first, object3); }); test('updateTileOverlays passes expected arguments', () async { @@ -424,20 +587,29 @@ void main() { final VerificationResult verification = verify(api.updateTileOverlays(captureAny, captureAny, captureAny)); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final List toAdd = + verification.captured[0] as List; + final List toChange = + verification.captured[1] as List; + final List toRemove = verification.captured[2] as List; + void expectTileOverlay(PlatformTileOverlay actual, TileOverlay expected) { + expect(actual.tileOverlayId, expected.tileOverlayId.value); + expect(actual.fadeIn, expected.fadeIn); + expect(actual.transparency, expected.transparency); + expect(actual.zIndex, expected.zIndex); + expect(actual.visible, expected.visible); + expect(actual.tileSize, expected.tileSize); + } + // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.tileOverlayId.value); // Object two should be changed. expect(toChange.length, 1); - expect(toChange.first?.json, object2new.toJson()); + expectTileOverlay(toChange.first, object2new); // Object 3 should be added. expect(toAdd.length, 1); - expect(toAdd.first?.json, object3.toJson()); + expectTileOverlay(toAdd.first, object3); }); test('markers send drag event to correct streams', () async { @@ -503,6 +675,45 @@ void main() { expect((await stream.next).value.value, equals(objectId)); }); + test('clusters send tap events to correct stream', () async { + const int mapId = 1; + const String managerId = 'manager-id'; + final PlatformLatLng fakePosition = + PlatformLatLng(latitude: 10, longitude: 20); + final PlatformLatLngBounds fakeBounds = PlatformLatLngBounds( + southwest: PlatformLatLng(latitude: 30, longitude: 40), + northeast: PlatformLatLng(latitude: 50, longitude: 60)); + const List markerIds = ['marker-1', 'marker-2']; + final PlatformCluster cluster = PlatformCluster( + clusterManagerId: managerId, + position: fakePosition, + bounds: fakeBounds, + markerIds: markerIds); + + final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final HostMapMessageHandler callbackHandler = + maps.ensureHandlerInitialized(mapId); + + final StreamQueue stream = + StreamQueue(maps.onClusterTap(mapId: mapId)); + + // Simulate message from the native side. + callbackHandler.onClusterTap(cluster); + + final Cluster eventValue = (await stream.next).value; + expect(eventValue.clusterManagerId.value, managerId); + expect(eventValue.position.latitude, fakePosition.latitude); + expect(eventValue.position.longitude, fakePosition.longitude); + expect(eventValue.bounds.southwest.latitude, fakeBounds.southwest.latitude); + expect( + eventValue.bounds.southwest.longitude, fakeBounds.southwest.longitude); + expect(eventValue.bounds.northeast.latitude, fakeBounds.northeast.latitude); + expect( + eventValue.bounds.northeast.longitude, fakeBounds.northeast.longitude); + expect(eventValue.markerIds.length, markerIds.length); + expect(eventValue.markerIds.first.value, markerIds.first); + }); + test('polygons send tap events to correct stream', () async { const int mapId = 1; const String objectId = 'object-id'; @@ -537,6 +748,217 @@ void main() { expect((await stream.next).value.value, equals(objectId)); }); + test('moveCamera calls through with expected newCameraPosition', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + const LatLng latLng = LatLng(10.0, 20.0); + const CameraPosition position = CameraPosition(target: latLng); + final CameraUpdate update = CameraUpdate.newCameraPosition(position); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateNewCameraPosition typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateNewCameraPosition; + update as CameraUpdateNewCameraPosition; + expect(typedUpdate.cameraPosition.target.latitude, + update.cameraPosition.target.latitude); + expect(typedUpdate.cameraPosition.target.longitude, + update.cameraPosition.target.longitude); + }); + + test('moveCamera calls through with expected newLatLng', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + const LatLng latLng = LatLng(10.0, 20.0); + final CameraUpdate update = CameraUpdate.newLatLng(latLng); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateNewLatLng typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLng; + update as CameraUpdateNewLatLng; + expect(typedUpdate.latLng.latitude, update.latLng.latitude); + expect(typedUpdate.latLng.longitude, update.latLng.longitude); + }); + + test('moveCamera calls through with expected newLatLngBounds', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + final LatLngBounds latLng = LatLngBounds( + northeast: const LatLng(10.0, 20.0), + southwest: const LatLng(9.0, 21.0)); + final CameraUpdate update = CameraUpdate.newLatLngBounds(latLng, 1.0); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateNewLatLngBounds typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngBounds; + update as CameraUpdateNewLatLngBounds; + expect(typedUpdate.bounds.northeast.latitude, + update.bounds.northeast.latitude); + expect(typedUpdate.bounds.northeast.longitude, + update.bounds.northeast.longitude); + expect(typedUpdate.bounds.southwest.latitude, + update.bounds.southwest.latitude); + expect(typedUpdate.bounds.southwest.longitude, + update.bounds.southwest.longitude); + expect(typedUpdate.padding, update.padding); + }); + + test('moveCamera calls through with expected newLatLngZoom', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + const LatLng latLng = LatLng(10.0, 20.0); + final CameraUpdate update = CameraUpdate.newLatLngZoom(latLng, 2.0); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateNewLatLngZoom typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngZoom; + update as CameraUpdateNewLatLngZoom; + expect(typedUpdate.latLng.latitude, update.latLng.latitude); + expect(typedUpdate.latLng.longitude, update.latLng.longitude); + expect(typedUpdate.zoom, update.zoom); + }); + + test('moveCamera calls through with expected zoomBy', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + const Offset focus = Offset(10.0, 20.0); + final CameraUpdate update = CameraUpdate.zoomBy(2.0, focus); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateZoomBy typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateZoomBy; + update as CameraUpdateZoomBy; + expect(typedUpdate.focus?.x, update.focus?.dx); + expect(typedUpdate.focus?.y, update.focus?.dy); + expect(typedUpdate.amount, update.amount); + }); + + test('moveCamera calls through with expected zoomTo', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + final CameraUpdate update = CameraUpdate.zoomTo(2.0); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateZoomTo typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateZoomTo; + update as CameraUpdateZoomTo; + expect(typedUpdate.zoom, update.zoom); + }); + + test('moveCamera calls through with expected zoomIn', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + final CameraUpdate update = CameraUpdate.zoomIn(); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateZoom typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; + expect(typedUpdate.out, false); + }); + + test('moveCamera calls through with expected zoomOut', () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = + setUpMockMap(mapId: mapId); + + final CameraUpdate update = CameraUpdate.zoomOut(); + await maps.moveCamera(update, mapId: mapId); + + final VerificationResult verification = verify(api.moveCamera(captureAny)); + final PlatformCameraUpdate passedUpdate = + verification.captured[0] as PlatformCameraUpdate; + final PlatformCameraUpdateZoom typedUpdate = + passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; + expect(typedUpdate.out, true); + }); + + test('MapBitmapScaling to PlatformMapBitmapScaling', () { + expect( + GoogleMapsFlutterIOS.platformMapBitmapScalingFromScaling( + MapBitmapScaling.auto), + PlatformMapBitmapScaling.auto); + expect( + GoogleMapsFlutterIOS.platformMapBitmapScalingFromScaling( + MapBitmapScaling.none), + PlatformMapBitmapScaling.none); + }); + + test('DefaultMarker bitmap to PlatformBitmap', () { + final BitmapDescriptor bitmap = BitmapDescriptor.defaultMarkerWithHue(10.0); + final PlatformBitmap platformBitmap = + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); + expect(platformBitmap.bitmap, isA()); + final PlatformBitmapDefaultMarker typedBitmap = + platformBitmap.bitmap as PlatformBitmapDefaultMarker; + expect(typedBitmap.hue, 10.0); + }); + + test('BytesMapBitmap bitmap to PlatformBitmap', () { + final Uint8List data = Uint8List.fromList([1, 2, 3, 4]); + final BytesMapBitmap bitmap = BitmapDescriptor.bytes(data, + imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final PlatformBitmap platformBitmap = + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); + expect(platformBitmap.bitmap, isA()); + final PlatformBitmapBytesMap typedBitmap = + platformBitmap.bitmap as PlatformBitmapBytesMap; + expect(typedBitmap.byteData, data); + expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); + expect(typedBitmap.imagePixelRatio, 2.0); + expect(typedBitmap.width, 100.0); + expect(typedBitmap.height, 200.0); + }); + + test('AssetMapBitmap bitmap to PlatformBitmap', () { + const String assetName = 'fake_asset_name'; + final AssetMapBitmap bitmap = AssetMapBitmap(assetName, + imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final PlatformBitmap platformBitmap = + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); + expect(platformBitmap.bitmap, isA()); + final PlatformBitmapAssetMap typedBitmap = + platformBitmap.bitmap as PlatformBitmapAssetMap; + expect(typedBitmap.assetName, assetName); + expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); + expect(typedBitmap.imagePixelRatio, 2.0); + expect(typedBitmap.width, 100.0); + expect(typedBitmap.height, 200.0); + }); + testWidgets('cloudMapId is passed', (WidgetTester tester) async { const String cloudMapId = '000000000000000'; // Dummy map ID. final Completer passedCloudMapIdCompleter = Completer();