@@ -62,6 +62,11 @@ class Convert {
62
62
63
63
private static BitmapDescriptor toBitmapDescriptor (
64
64
Object o , AssetManager assetManager , float density ) {
65
+ return toBitmapDescriptor (o , assetManager , density , new BitmapDescriptorFactoryWrapper ());
66
+ }
67
+
68
+ private static BitmapDescriptor toBitmapDescriptor (
69
+ Object o , AssetManager assetManager , float density , BitmapDescriptorFactoryWrapper wrapper ) {
65
70
final List <?> data = toList (o );
66
71
final String descriptorType = toString (data .get (0 ));
67
72
switch (descriptorType ) {
@@ -101,17 +106,13 @@ private static BitmapDescriptor toBitmapDescriptor(
101
106
}
102
107
final Map <?, ?> assetData = toMap (data .get (1 ));
103
108
return getBitmapFromAsset (
104
- assetData ,
105
- assetManager ,
106
- density ,
107
- new BitmapDescriptorFactoryWrapper (),
108
- new FlutterInjectorWrapper ());
109
+ assetData , assetManager , density , wrapper , new FlutterInjectorWrapper ());
109
110
case "bytes" :
110
111
if (!(data .get (1 ) instanceof Map )) {
111
112
throw new IllegalArgumentException ("'bytes' expected a map as the second parameter" );
112
113
}
113
114
final Map <?, ?> byteData = toMap (data .get (1 ));
114
- return getBitmapFromBytes (byteData , density , new BitmapDescriptorFactoryWrapper () );
115
+ return getBitmapFromBytes (byteData , density , wrapper );
115
116
default :
116
117
throw new IllegalArgumentException ("Cannot interpret " + o + " as BitmapDescriptor" );
117
118
}
@@ -659,68 +660,34 @@ static void interpretMapConfiguration(
659
660
660
661
/** Set the options in the given object to marker options sink. */
661
662
static void interpretMarkerOptions (
662
- Map <String , ?> data , MarkerOptionsSink sink , AssetManager assetManager , float density ) {
663
- final Object alpha = data .get ("alpha" );
664
- if (alpha != null ) {
665
- sink .setAlpha (toFloat (alpha ));
666
- }
667
- final Object anchor = data .get ("anchor" );
668
- if (anchor != null ) {
669
- final List <?> anchorData = toList (anchor );
670
- sink .setAnchor (toFloat (anchorData .get (0 )), toFloat (anchorData .get (1 )));
671
- }
672
- final Object consumeTapEvents = data .get ("consumeTapEvents" );
673
- if (consumeTapEvents != null ) {
674
- sink .setConsumeTapEvents (toBoolean (consumeTapEvents ));
675
- }
676
- final Object draggable = data .get ("draggable" );
677
- if (draggable != null ) {
678
- sink .setDraggable (toBoolean (draggable ));
679
- }
680
- final Object flat = data .get ("flat" );
681
- if (flat != null ) {
682
- sink .setFlat (toBoolean (flat ));
683
- }
684
- final Object icon = data .get ("icon" );
685
- if (icon != null ) {
686
- sink .setIcon (toBitmapDescriptor (icon , assetManager , density ));
687
- }
688
-
689
- final Object infoWindow = data .get ("infoWindow" );
690
- if (infoWindow != null ) {
691
- interpretInfoWindowOptions (sink , toObjectMap (infoWindow ));
692
- }
693
- final Object position = data .get ("position" );
694
- if (position != null ) {
695
- sink .setPosition (toLatLng (position ));
696
- }
697
- final Object rotation = data .get ("rotation" );
698
- if (rotation != null ) {
699
- sink .setRotation (toFloat (rotation ));
700
- }
701
- final Object visible = data .get ("visible" );
702
- if (visible != null ) {
703
- sink .setVisible (toBoolean (visible ));
704
- }
705
- final Object zIndex = data .get ("zIndex" );
706
- if (zIndex != null ) {
707
- sink .setZIndex (toFloat (zIndex ));
708
- }
663
+ Messages .PlatformMarker marker ,
664
+ MarkerOptionsSink sink ,
665
+ AssetManager assetManager ,
666
+ float density ,
667
+ BitmapDescriptorFactoryWrapper wrapper ) {
668
+ sink .setAlpha (marker .getAlpha ().floatValue ());
669
+ sink .setAnchor (
670
+ marker .getAnchor ().getDx ().floatValue (), marker .getAnchor ().getDy ().floatValue ());
671
+ sink .setConsumeTapEvents (marker .getConsumeTapEvents ());
672
+ sink .setDraggable (marker .getDraggable ());
673
+ sink .setFlat (marker .getFlat ());
674
+ sink .setIcon (toBitmapDescriptor (marker .getIcon (), assetManager , density , wrapper ));
675
+ interpretInfoWindowOptions (sink , marker .getInfoWindow ());
676
+ sink .setPosition (toLatLng (marker .getPosition ().toList ()));
677
+ sink .setRotation (marker .getRotation ().floatValue ());
678
+ sink .setVisible (marker .getVisible ());
679
+ sink .setZIndex (marker .getZIndex ().floatValue ());
709
680
}
710
681
711
682
private static void interpretInfoWindowOptions (
712
- MarkerOptionsSink sink , Map <String , Object > infoWindow ) {
713
- String title = (String ) infoWindow .get ("title" );
714
- String snippet = (String ) infoWindow .get ("snippet" );
715
- // snippet is nullable.
683
+ MarkerOptionsSink sink , Messages .PlatformInfoWindow infoWindow ) {
684
+ String title = infoWindow .getTitle ();
716
685
if (title != null ) {
717
- sink .setInfoWindowText (title , snippet );
718
- }
719
- Object infoWindowAnchor = infoWindow .get ("anchor" );
720
- if (infoWindowAnchor != null ) {
721
- final List <?> anchorData = toList (infoWindowAnchor );
722
- sink .setInfoWindowAnchor (toFloat (anchorData .get (0 )), toFloat (anchorData .get (1 )));
686
+ sink .setInfoWindowText (title , infoWindow .getSnippet ());
723
687
}
688
+ Messages .PlatformOffset infoWindowAnchor = infoWindow .getAnchor ();
689
+ sink .setInfoWindowAnchor (
690
+ infoWindowAnchor .getDx ().floatValue (), infoWindowAnchor .getDy ().floatValue ());
724
691
}
725
692
726
693
static String interpretPolygonOptions (Map <String , ?> data , PolygonOptionsSink sink ) {
@@ -822,45 +789,16 @@ static String interpretPolylineOptions(
822
789
}
823
790
}
824
791
825
- static String interpretCircleOptions (Map <String , ?> data , CircleOptionsSink sink ) {
826
- final Object consumeTapEvents = data .get ("consumeTapEvents" );
827
- if (consumeTapEvents != null ) {
828
- sink .setConsumeTapEvents (toBoolean (consumeTapEvents ));
829
- }
830
- final Object fillColor = data .get ("fillColor" );
831
- if (fillColor != null ) {
832
- sink .setFillColor (toInt (fillColor ));
833
- }
834
- final Object strokeColor = data .get ("strokeColor" );
835
- if (strokeColor != null ) {
836
- sink .setStrokeColor (toInt (strokeColor ));
837
- }
838
- final Object visible = data .get ("visible" );
839
- if (visible != null ) {
840
- sink .setVisible (toBoolean (visible ));
841
- }
842
- final Object strokeWidth = data .get ("strokeWidth" );
843
- if (strokeWidth != null ) {
844
- sink .setStrokeWidth (toInt (strokeWidth ));
845
- }
846
- final Object zIndex = data .get ("zIndex" );
847
- if (zIndex != null ) {
848
- sink .setZIndex (toFloat (zIndex ));
849
- }
850
- final Object center = data .get ("center" );
851
- if (center != null ) {
852
- sink .setCenter (toLatLng (center ));
853
- }
854
- final Object radius = data .get ("radius" );
855
- if (radius != null ) {
856
- sink .setRadius (toDouble (radius ));
857
- }
858
- final String circleId = (String ) data .get ("circleId" );
859
- if (circleId == null ) {
860
- throw new IllegalArgumentException ("circleId was null" );
861
- } else {
862
- return circleId ;
863
- }
792
+ static String interpretCircleOptions (Messages .PlatformCircle circle , CircleOptionsSink sink ) {
793
+ sink .setConsumeTapEvents (circle .getConsumeTapEvents ());
794
+ sink .setFillColor (circle .getFillColor ().intValue ());
795
+ sink .setStrokeColor (circle .getStrokeColor ().intValue ());
796
+ sink .setStrokeWidth (circle .getStrokeWidth ());
797
+ sink .setZIndex (circle .getZIndex ().floatValue ());
798
+ sink .setCenter (toLatLng (circle .getCenter ().toList ()));
799
+ sink .setRadius (circle .getRadius ());
800
+ sink .setVisible (circle .getVisible ());
801
+ return circle .getCircleId ();
864
802
}
865
803
866
804
/**
@@ -1069,7 +1007,6 @@ static Tile tileFromPigeon(Messages.PlatformTile tile) {
1069
1007
return new Tile (tile .getWidth ().intValue (), tile .getHeight ().intValue (), tile .getData ());
1070
1008
}
1071
1009
1072
- @ VisibleForTesting
1073
1010
static class BitmapDescriptorFactoryWrapper {
1074
1011
/**
1075
1012
* Creates a BitmapDescriptor from the provided asset key using the {@link
0 commit comments