Skip to content

Commit 5b61f58

Browse files
committed
Fix after rebase
1 parent 0ecffad commit 5b61f58

File tree

10 files changed

+92
-32
lines changed

10 files changed

+92
-32
lines changed

packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ private static BitmapDescriptor toBitmapDescriptor(
119119
Messages.PlatformBitmapBytesMap typedBitmap = (Messages.PlatformBitmapBytesMap) bitmap;
120120
return getBitmapFromBytes(typedBitmap, density, wrapper);
121121
}
122+
if (bitmap instanceof Messages.PlatformBitmapPinConfig) {
123+
Messages.PlatformBitmapPinConfig pinConfigBitmap = (Messages.PlatformBitmapPinConfig) bitmap;
124+
return getBitmapFromPinConfig(pinConfigBitmap, assetManager, density, wrapper);
125+
}
122126
throw new IllegalArgumentException("PlatformBitmap did not contain a supported subtype.");
123127
}
124128

@@ -190,7 +194,7 @@ public static BitmapDescriptor getBitmapFromBytes(
190194
}
191195

192196
public static BitmapDescriptor getBitmapFromPinConfig(
193-
Map<?, ?> byteData,
197+
Messages.PlatformBitmapPinConfig pinConfigBitmap,
194198
AssetManager assetManager,
195199
float density,
196200
BitmapDescriptorFactoryWrapper bitmapDescriptorFactory
@@ -204,17 +208,19 @@ public static BitmapDescriptor getBitmapFromPinConfig(
204208
final String glyphBitmapDescriptorKey = "glyphBitmapDescriptor";
205209

206210
final Integer backgroundColor =
207-
byteData.containsKey(backgroundColorKey) ? toInt(byteData.get(backgroundColorKey)) : null;
211+
pinConfigBitmap.getBackgroundColor() != null ? toInt(pinConfigBitmap.getBackgroundColor())
212+
: null;
208213
final Integer borderColor =
209-
byteData.containsKey(borderColorKey) ? toInt(byteData.get(borderColorKey)) : null;
214+
pinConfigBitmap.getBorderColor() != null ? toInt(pinConfigBitmap.getBorderColor()) : null;
210215
final String glyphText =
211-
byteData.containsKey(glyphTextKey) ? toString(byteData.get(glyphTextKey)) : null;
216+
pinConfigBitmap.getGlyphText() != null ? pinConfigBitmap.getGlyphText() : null;
212217
final Integer glyphTextColor =
213-
byteData.containsKey(glyphTextColorKey) ? toInt(byteData.get(glyphTextColorKey)) : null;
218+
pinConfigBitmap.getGlyphTextColor() != null ? toInt(pinConfigBitmap.getGlyphTextColor())
219+
: null;
214220
final Integer glyphColor =
215-
byteData.containsKey(glyphColorKey) ? toInt(byteData.get(glyphColorKey)) : null;
216-
final BitmapDescriptor glyphBitmapDescriptor = byteData.containsKey(glyphBitmapDescriptorKey)
217-
? toBitmapDescriptor(byteData.get(glyphBitmapDescriptorKey), assetManager, density)
221+
pinConfigBitmap.getGlyphColor() != null ? toInt(pinConfigBitmap.getGlyphColor()) : null;
222+
final BitmapDescriptor glyphBitmapDescriptor = pinConfigBitmap.getGlyphBitmap() != null
223+
? toBitmapDescriptor(pinConfigBitmap.getGlyphBitmap(), assetManager, density)
218224
: null;
219225

220226
final PinConfig.Builder pinConfigBuilder = PinConfig.builder();

packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ConvertTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,14 @@ public void GetBitmapFromBytesThrowsErrorIfInvalidImageData() {
336336

337337
@Test
338338
public void GetBitmapFromPinConfig() {
339-
Map<String, Object> assetDetails = new HashMap<>();
340-
assetDetails.put("backgroundColor", 0xFFFFFFFF);
341-
assetDetails.put("borderColor", 0xFFFFFFFF);
339+
Messages.PlatformBitmapPinConfig bitmap = new Messages.PlatformBitmapPinConfig.Builder()
340+
.setBackgroundColor(0xFFFFFFL)
341+
.setBorderColor(0xFFFFFFL)
342+
.build();
342343

343344
when(bitmapDescriptorFactoryWrapper.fromPinConfig(any())).thenReturn(mockBitmapDescriptor);
344-
BitmapDescriptor result = Convert.getBitmapFromPinConfig(
345-
assetDetails, assetManager, 1f, bitmapDescriptorFactoryWrapper);
345+
BitmapDescriptor result = Convert.getBitmapFromPinConfig(bitmap, assetManager, 1f,
346+
bitmapDescriptorFactoryWrapper);
346347
Assert.assertEquals(mockBitmapDescriptor, result);
347348
}
348349

packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_marker.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ class PlaceMarkerBodyState extends State<PlaceMarkerBody> {
4444
int _markerIdCounter = 1;
4545
LatLng? markerPosition;
4646

47-
// ignore: use_setters_to_change_properties
4847
void _onMapCreated(ExampleGoogleMapController controller) {
49-
this.controller = controller;
48+
setState(() {
49+
this.controller = controller;
50+
});
5051
}
5152

5253
@override

packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,21 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
10221022
imagePixelRatio: bytes.imagePixelRatio,
10231023
width: bytes.width,
10241024
height: bytes.height));
1025+
case final PinConfig pinConfig:
1026+
final BitmapDescriptor? glyphBitmapDescriptor =
1027+
pinConfig.glyph?.bitmapDescriptor;
1028+
return PlatformBitmap(
1029+
bitmap: PlatformBitmapPinConfig(
1030+
backgroundColor: pinConfig.backgroundColor?.value,
1031+
borderColor: pinConfig.borderColor?.value,
1032+
glyphColor: pinConfig.glyph?.color?.value,
1033+
glyphText: pinConfig.glyph?.text,
1034+
glyphTextColor: pinConfig.glyph?.textColor?.value,
1035+
glyphBitmap: glyphBitmapDescriptor != null
1036+
? platformBitmapFromBitmapDescriptor(glyphBitmapDescriptor)
1037+
: null,
1038+
),
1039+
);
10251040
default:
10261041
throw ArgumentError(
10271042
'Unrecognized type of bitmap ${bitmap.runtimeType}', 'bitmap');

packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,25 @@ class PlatformBitmapBytesMap {
637637
final double? height;
638638
}
639639

640+
class PlatformBitmapPinConfig {
641+
PlatformBitmapPinConfig({
642+
required this.backgroundColor,
643+
required this.borderColor,
644+
required this.glyphColor,
645+
required this.glyphBitmap,
646+
required this.glyphText,
647+
required this.glyphTextColor,
648+
});
649+
650+
final int? backgroundColor;
651+
final int? borderColor;
652+
final int? glyphColor;
653+
final PlatformBitmap? glyphBitmap;
654+
655+
final String? glyphText;
656+
final int? glyphTextColor;
657+
}
658+
640659
/// Interface for non-test interactions with the native SDK.
641660
///
642661
/// For test-only state queries, see [MapsInspectorApi].

packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -521,20 +521,25 @@ void main() {
521521
expect(toChange.length, 1);
522522
final List<Object?>? encoded = toChange.first?.encode() as List<Object?>?;
523523
expect(encoded?[0], object2new.alpha);
524-
final PlatformOffset? offset = encoded?[1] as PlatformOffset?;
525-
expect(offset?.dx, object2new.anchor.dx);
526-
expect(offset?.dy, object2new.anchor.dy);
527-
expect(encoded?.getRange(2, 6).toList(), <Object?>[
524+
final PlatformDoublePair? offset = encoded?[1] as PlatformDoublePair?;
525+
expect(offset?.x, object2new.anchor.dx);
526+
expect(offset?.y, object2new.anchor.dy);
527+
expect(encoded?.getRange(2, 5).toList(), <Object?>[
528528
object2new.consumeTapEvents,
529529
object2new.draggable,
530530
object2new.flat,
531-
object2new.icon.toJson(),
532531
]);
532+
expect(
533+
(encoded?[5] as PlatformBitmap?)?.bitmap.runtimeType,
534+
GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(
535+
object2new.icon)
536+
.bitmap
537+
.runtimeType);
533538
final PlatformInfoWindow? window = encoded?[6] as PlatformInfoWindow?;
534539
expect(window?.title, object2new.infoWindow.title);
535540
expect(window?.snippet, object2new.infoWindow.snippet);
536-
expect(window?.anchor.dx, object2new.infoWindow.anchor.dx);
537-
expect(window?.anchor.dy, object2new.infoWindow.anchor.dy);
541+
expect(window?.anchor.x, object2new.infoWindow.anchor.dx);
542+
expect(window?.anchor.y, object2new.infoWindow.anchor.dy);
538543
final PlatformLatLng? latLng = encoded?[7] as PlatformLatLng?;
539544
expect(latLng?.latitude, object2new.position.latitude);
540545
expect(latLng?.longitude, object2new.position.longitude);
@@ -551,20 +556,25 @@ void main() {
551556
expect(toAdd.length, 1);
552557
final List<Object?>? encoded = toAdd.first?.encode() as List<Object?>?;
553558
expect(encoded?[0], object3.alpha);
554-
final PlatformOffset? offset = encoded?[1] as PlatformOffset?;
555-
expect(offset?.dx, object3.anchor.dx);
556-
expect(offset?.dy, object3.anchor.dy);
557-
expect(encoded?.getRange(2, 6).toList(), <Object?>[
559+
final PlatformDoublePair? offset = encoded?[1] as PlatformDoublePair?;
560+
expect(offset?.x, object3.anchor.dx);
561+
expect(offset?.y, object3.anchor.dy);
562+
expect(encoded?.getRange(2, 5).toList(), <Object?>[
558563
object3.consumeTapEvents,
559564
object3.draggable,
560565
object3.flat,
561-
object3.icon.toJson(),
562566
]);
567+
expect(
568+
(encoded?[5] as PlatformBitmap?)?.bitmap.runtimeType,
569+
GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(
570+
object3.icon)
571+
.bitmap
572+
.runtimeType);
563573
final PlatformInfoWindow? window = encoded?[6] as PlatformInfoWindow?;
564574
expect(window?.title, object3.infoWindow.title);
565575
expect(window?.snippet, object3.infoWindow.snippet);
566-
expect(window?.anchor.dx, object3.infoWindow.anchor.dx);
567-
expect(window?.anchor.dy, object3.infoWindow.anchor.dy);
576+
expect(window?.anchor.x, object3.infoWindow.anchor.dx);
577+
expect(window?.anchor.y, object3.infoWindow.anchor.dy);
568578
final PlatformLatLng? latLng = encoded?[7] as PlatformLatLng?;
569579
expect(latLng?.latitude, object3.position.latitude);
570580
expect(latLng?.longitude, object3.position.longitude);

packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_marker.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ class PlaceMarkerBodyState extends State<PlaceMarkerBody> {
4848
// A helper text for Xcode UITests.
4949
String _onDragXcodeUITestHelperText = '';
5050

51-
// ignore: use_setters_to_change_properties
5251
void _onMapCreated(ExampleGoogleMapController controller) {
53-
this.controller = controller;
52+
setState(() {
53+
this.controller = controller;
54+
});
5455
}
5556

5657
@override

packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ class PlatformMapViewCreationParams {
415415
final PlatformMarkerType markerType;
416416
}
417417

418+
enum PlatformMarkerType {
419+
marker,
420+
advancedMarker,
421+
}
422+
418423
/// Pigeon equivalent of MapConfiguration.
419424
class PlatformMapConfiguration {
420425
PlatformMapConfiguration({

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ class PinConfig extends BitmapDescriptor {
10461046
backgroundColor != null || borderColor != null || glyph != null,
10471047
'Cannot create PinConfig with all parameters being null.',
10481048
),
1049-
super._(const <Object>[]);
1049+
super._();
10501050

10511051
/// The type of the MapBitmap object, used for the JSON serialization.
10521052
static const String type = 'pinConfig';

packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/bitmap_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ void main() {
757757
],
758758
);
759759
});
760+
});
761+
760762
test('mapBitmapScaling from String', () {
761763
expect(mapBitmapScalingFromString('auto'), MapBitmapScaling.auto);
762764
expect(mapBitmapScalingFromString('none'), MapBitmapScaling.none);

0 commit comments

Comments
 (0)