@@ -16,6 +16,7 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
16
16
import 'package:stream_transform/stream_transform.dart' ;
17
17
18
18
import '../types/tile_overlay_updates.dart' ;
19
+ import '../types/utils/map_configuration_serialization.dart' ;
19
20
20
21
/// Error thrown when an unknown map ID is provided to a method channel API.
21
22
class UnknownMapIDError extends Error {
@@ -484,28 +485,22 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
484
485
/// Defaults to false.
485
486
bool useAndroidViewSurface = false ;
486
487
487
- @override
488
- Widget buildViewWithTextDirection (
488
+ Widget _buildView (
489
489
int creationId,
490
490
PlatformViewCreatedCallback onPlatformViewCreated, {
491
- required CameraPosition initialCameraPosition,
492
- required TextDirection textDirection,
493
- Set <Marker > markers = const < Marker > {},
494
- Set <Polygon > polygons = const < Polygon > {},
495
- Set <Polyline > polylines = const < Polyline > {},
496
- Set <Circle > circles = const < Circle > {},
497
- Set <TileOverlay > tileOverlays = const < TileOverlay > {},
498
- Set <Factory <OneSequenceGestureRecognizer >>? gestureRecognizers,
491
+ required MapWidgetConfiguration widgetConfiguration,
492
+ MapObjects mapObjects = const MapObjects (),
499
493
Map <String , dynamic > mapOptions = const < String , dynamic > {},
500
494
}) {
501
495
final Map <String , dynamic > creationParams = < String , dynamic > {
502
- 'initialCameraPosition' : initialCameraPosition.toMap (),
496
+ 'initialCameraPosition' :
497
+ widgetConfiguration.initialCameraPosition.toMap (),
503
498
'options' : mapOptions,
504
- 'markersToAdd' : serializeMarkerSet (markers),
505
- 'polygonsToAdd' : serializePolygonSet (polygons),
506
- 'polylinesToAdd' : serializePolylineSet (polylines),
507
- 'circlesToAdd' : serializeCircleSet (circles),
508
- 'tileOverlaysToAdd' : serializeTileOverlaySet (tileOverlays),
499
+ 'markersToAdd' : serializeMarkerSet (mapObjects. markers),
500
+ 'polygonsToAdd' : serializePolygonSet (mapObjects. polygons),
501
+ 'polylinesToAdd' : serializePolylineSet (mapObjects. polylines),
502
+ 'circlesToAdd' : serializeCircleSet (mapObjects. circles),
503
+ 'tileOverlaysToAdd' : serializeTileOverlaySet (mapObjects. tileOverlays),
509
504
};
510
505
511
506
if (defaultTargetPlatform == TargetPlatform .android) {
@@ -518,8 +513,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
518
513
) {
519
514
return AndroidViewSurface (
520
515
controller: controller as AndroidViewController ,
521
- gestureRecognizers: gestureRecognizers ??
522
- const < Factory <OneSequenceGestureRecognizer >> {},
516
+ gestureRecognizers: widgetConfiguration.gestureRecognizers,
523
517
hitTestBehavior: PlatformViewHitTestBehavior .opaque,
524
518
);
525
519
},
@@ -528,7 +522,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
528
522
PlatformViewsService .initSurfaceAndroidView (
529
523
id: params.id,
530
524
viewType: 'plugins.flutter.io/google_maps' ,
531
- layoutDirection: textDirection,
525
+ layoutDirection: widgetConfiguration. textDirection,
532
526
creationParams: creationParams,
533
527
creationParamsCodec: const StandardMessageCodec (),
534
528
onFocus: () => params.onFocusChanged (true ),
@@ -548,7 +542,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
548
542
return AndroidView (
549
543
viewType: 'plugins.flutter.io/google_maps' ,
550
544
onPlatformViewCreated: onPlatformViewCreated,
551
- gestureRecognizers: gestureRecognizers,
545
+ gestureRecognizers: widgetConfiguration. gestureRecognizers,
552
546
creationParams: creationParams,
553
547
creationParamsCodec: const StandardMessageCodec (),
554
548
);
@@ -557,7 +551,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
557
551
return UiKitView (
558
552
viewType: 'plugins.flutter.io/google_maps' ,
559
553
onPlatformViewCreated: onPlatformViewCreated,
560
- gestureRecognizers: gestureRecognizers,
554
+ gestureRecognizers: widgetConfiguration. gestureRecognizers,
561
555
creationParams: creationParams,
562
556
creationParamsCodec: const StandardMessageCodec (),
563
557
);
@@ -567,6 +561,53 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
567
561
'$defaultTargetPlatform is not yet supported by the maps plugin' );
568
562
}
569
563
564
+ @override
565
+ Widget buildViewWithConfiguration (
566
+ int creationId,
567
+ PlatformViewCreatedCallback onPlatformViewCreated, {
568
+ required MapWidgetConfiguration widgetConfiguration,
569
+ MapConfiguration mapConfiguration = const MapConfiguration (),
570
+ MapObjects mapObjects = const MapObjects (),
571
+ }) {
572
+ return _buildView (
573
+ creationId,
574
+ onPlatformViewCreated,
575
+ widgetConfiguration: widgetConfiguration,
576
+ mapObjects: mapObjects,
577
+ mapOptions: jsonForMapConfiguration (mapConfiguration),
578
+ );
579
+ }
580
+
581
+ @override
582
+ Widget buildViewWithTextDirection (
583
+ int creationId,
584
+ PlatformViewCreatedCallback onPlatformViewCreated, {
585
+ required CameraPosition initialCameraPosition,
586
+ required TextDirection textDirection,
587
+ Set <Marker > markers = const < Marker > {},
588
+ Set <Polygon > polygons = const < Polygon > {},
589
+ Set <Polyline > polylines = const < Polyline > {},
590
+ Set <Circle > circles = const < Circle > {},
591
+ Set <TileOverlay > tileOverlays = const < TileOverlay > {},
592
+ Set <Factory <OneSequenceGestureRecognizer >>? gestureRecognizers,
593
+ Map <String , dynamic > mapOptions = const < String , dynamic > {},
594
+ }) {
595
+ return _buildView (
596
+ creationId,
597
+ onPlatformViewCreated,
598
+ widgetConfiguration: MapWidgetConfiguration (
599
+ initialCameraPosition: initialCameraPosition,
600
+ textDirection: textDirection),
601
+ mapObjects: MapObjects (
602
+ markers: markers,
603
+ polygons: polygons,
604
+ polylines: polylines,
605
+ circles: circles,
606
+ tileOverlays: tileOverlays),
607
+ mapOptions: mapOptions,
608
+ );
609
+ }
610
+
570
611
@override
571
612
Widget buildView (
572
613
int creationId,
0 commit comments