@@ -16,6 +16,62 @@ Map<int, String> _mapTypeToMapTypeId = <int, String>{
1616 4 : 'hybrid' ,
1717};
1818
19+ // Builds the raw map options map from a [MapConfiguration].
20+ //
21+ // This mirrors the platform interface's `jsonForMapConfiguration` helper
22+ // (which is not exported), plus [MapConfiguration.colorScheme].
23+ //
24+ // Intentionally omitted:
25+ // * `cloudMapId` — deprecated alias for `mapId`, which is already serialized.
26+ // * `markerType` — only relevant to advanced markers, which are not supported
27+ // on Tizen.
28+ Map <String , dynamic > _mapOptionsFromConfiguration (MapConfiguration config) {
29+ final EdgeInsets ? padding = config.padding;
30+ return < String , dynamic > {
31+ if (config.compassEnabled != null ) 'compassEnabled' : config.compassEnabled,
32+ if (config.mapToolbarEnabled != null )
33+ 'mapToolbarEnabled' : config.mapToolbarEnabled,
34+ if (config.cameraTargetBounds != null )
35+ 'cameraTargetBounds' : config.cameraTargetBounds! .toJson (),
36+ if (config.mapType != null ) 'mapType' : config.mapType! .index,
37+ if (config.minMaxZoomPreference != null )
38+ 'minMaxZoomPreference' : config.minMaxZoomPreference! .toJson (),
39+ if (config.rotateGesturesEnabled != null )
40+ 'rotateGesturesEnabled' : config.rotateGesturesEnabled,
41+ if (config.scrollGesturesEnabled != null )
42+ 'scrollGesturesEnabled' : config.scrollGesturesEnabled,
43+ if (config.tiltGesturesEnabled != null )
44+ 'tiltGesturesEnabled' : config.tiltGesturesEnabled,
45+ if (config.zoomControlsEnabled != null )
46+ 'zoomControlsEnabled' : config.zoomControlsEnabled,
47+ if (config.zoomGesturesEnabled != null )
48+ 'zoomGesturesEnabled' : config.zoomGesturesEnabled,
49+ if (config.liteModeEnabled != null )
50+ 'liteModeEnabled' : config.liteModeEnabled,
51+ if (config.trackCameraPosition != null )
52+ 'trackCameraPosition' : config.trackCameraPosition,
53+ if (config.myLocationEnabled != null )
54+ 'myLocationEnabled' : config.myLocationEnabled,
55+ if (config.myLocationButtonEnabled != null )
56+ 'myLocationButtonEnabled' : config.myLocationButtonEnabled,
57+ if (padding != null )
58+ 'padding' : < double > [
59+ padding.top,
60+ padding.left,
61+ padding.bottom,
62+ padding.right,
63+ ],
64+ if (config.indoorViewEnabled != null )
65+ 'indoorEnabled' : config.indoorViewEnabled,
66+ if (config.trafficEnabled != null ) 'trafficEnabled' : config.trafficEnabled,
67+ if (config.buildingsEnabled != null )
68+ 'buildingsEnabled' : config.buildingsEnabled,
69+ if (config.mapId != null ) 'mapId' : config.mapId,
70+ if (config.style != null ) 'style' : config.style,
71+ if (config.colorScheme != null ) 'colorScheme' : config.colorScheme! .index,
72+ };
73+ }
74+
1975String ? _getCameraBounds (dynamic option) {
2076 if (option is ! List <Object ?> || option.first == null ) {
2177 return null ;
@@ -90,9 +146,33 @@ String _rawOptionsToString(Map<String, dynamic> rawOptions) {
90146 options += ", gestureHandling: 'auto'" ;
91147 }
92148
149+ final String ? colorScheme = _colorSchemeToJs (rawOptions['colorScheme' ]);
150+ if (colorScheme != null ) {
151+ options += ', colorScheme: $colorScheme ' ;
152+ }
153+
93154 return options;
94155}
95156
157+ // Maps a serialized MapColorScheme value from the platform interface to the
158+ // JavaScript google.maps.ColorScheme enum.
159+ String ? _colorSchemeToJs (Object ? value) {
160+ if (value is ! int ) {
161+ return null ;
162+ }
163+ // The platform interface serializes MapColorScheme as its enum index:
164+ // 0 = light, 1 = dark, 2 = followSystem.
165+ switch (value) {
166+ case 0 :
167+ return 'google.maps.ColorScheme.LIGHT' ;
168+ case 1 :
169+ return 'google.maps.ColorScheme.DARK' ;
170+ case 2 :
171+ return 'google.maps.ColorScheme.FOLLOW_SYSTEM' ;
172+ }
173+ return null ;
174+ }
175+
96176String _applyInitialPosition (CameraPosition initialPosition, String options) {
97177 options += ', zoom: ${initialPosition .zoom }' ;
98178 options +=
@@ -400,3 +480,56 @@ util.GCircleOptions _circleOptionsFromCircle(Circle circle) {
400480 ..visible = circle.visible
401481 ..zIndex = circle.zIndex;
402482}
483+
484+ util.GGroundOverlayOptions ? _groundOverlayOptionsFromGroundOverlay (
485+ GroundOverlay groundOverlay,
486+ ) {
487+ // The JS Maps GroundOverlay only supports bounds-based positioning. Skip
488+ // position-only overlays — the platform interface allows the field but the
489+ // JS API has no equivalent.
490+ final LatLngBounds ? bounds = groundOverlay.bounds;
491+ if (bounds == null ) {
492+ debugPrint (
493+ 'GroundOverlay ${groundOverlay .groundOverlayId .value } skipped: '
494+ 'the Google Maps JavaScript API only supports bounds-based '
495+ 'ground overlays.' ,
496+ );
497+ return null ;
498+ }
499+ final String ? imageUrl = _imageUrlFromMapBitmap (groundOverlay.image);
500+ if (imageUrl == null ) {
501+ debugPrint (
502+ 'GroundOverlay ${groundOverlay .groundOverlayId .value } skipped: '
503+ 'unsupported image source.' ,
504+ );
505+ return null ;
506+ }
507+ return util.GGroundOverlayOptions ()
508+ ..url = "'$imageUrl '"
509+ ..bounds = '{south:${bounds .southwest .latitude },'
510+ ' west:${bounds .southwest .longitude },'
511+ ' north:${bounds .northeast .latitude },'
512+ ' east:${bounds .northeast .longitude }}'
513+ ..clickable = groundOverlay.clickable
514+ ..opacity = 1.0 - groundOverlay.transparency
515+ ..visible = groundOverlay.visible;
516+ }
517+
518+ String ? _imageUrlFromMapBitmap (MapBitmap bitmap) {
519+ final List <Object ?> iconConfig = bitmap.toJson () as List <Object ?>;
520+ if (iconConfig.isEmpty) {
521+ return null ;
522+ }
523+ if (iconConfig[0 ] == 'asset' && iconConfig.length >= 2 ) {
524+ final Map <String , Object ?> assetConfig =
525+ iconConfig[1 ]! as Map <String , Object ?>;
526+ return '../${assetConfig ['assetName' ]}' ;
527+ }
528+ if (iconConfig[0 ] == 'bytes' && iconConfig.length >= 2 ) {
529+ final Map <String , Object ?> assetConfig =
530+ iconConfig[1 ]! as Map <String , Object ?>;
531+ final List <int > bytes = assetConfig['byteData' ]! as List <int >;
532+ return 'data:image/png;base64,${base64Encode (bytes )}' ;
533+ }
534+ return null ;
535+ }
0 commit comments