Skip to content

Commit 628d6b6

Browse files
committed
Move MarkerType to MapConfiguration
1 parent a37dc97 commit 628d6b6

File tree

29 files changed

+131
-131
lines changed

29 files changed

+131
-131
lines changed

packages/google_maps_flutter/google_maps_flutter/example/lib/clustering.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'dart:math';
66

77
import 'package:flutter/material.dart';
88
import 'package:google_maps_flutter/google_maps_flutter.dart';
9-
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
109

1110
import 'page.dart';
1211

packages/google_maps_flutter/google_maps_flutter/example/lib/marker_icons.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'dart:async';
1010
import 'package:flutter/foundation.dart';
1111
import 'package:flutter/material.dart';
1212
import 'package:google_maps_flutter/google_maps_flutter.dart';
13-
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
1413

1514
import 'custom_marker_icon.dart';
1615
import 'page.dart';

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'dart:typed_data';
1010

1111
import 'package:flutter/material.dart';
1212
import 'package:google_maps_flutter/google_maps_flutter.dart';
13-
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
1413

1514
import 'custom_marker_icon.dart';
1615
import 'page.dart';

packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample_advanced_markers.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import 'package:flutter/material.dart';
88
import 'package:google_maps_flutter/google_maps_flutter.dart';
9-
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
109

1110
void main() => runApp(const MyApp());
1211

packages/google_maps_flutter/google_maps_flutter/lib/google_maps_flutter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'dart:async';
99
import 'package:flutter/foundation.dart';
1010
import 'package:flutter/gestures.dart';
1111
import 'package:flutter/material.dart';
12+
import 'package:flutter/services.dart';
1213
import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
1314
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
1415

@@ -43,6 +44,7 @@ export 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
4344
MapType,
4445
Marker,
4546
MarkerId,
47+
MarkerType,
4648
MinMaxZoomPreference,
4749
PatternItem,
4850
Polygon,

packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,18 @@ class GoogleMap extends StatefulWidget {
324324
/// for more details.
325325
final String? mapId;
326326

327-
/// Indicates whether map should use [AdvancedMarker]s or [Marker]s.
327+
/// Indicates whether map uses [AdvancedMarker]s or [Marker]s.
328+
///
329+
/// [AdvancedMarker] and [Marker]s classes might not be related to each other
330+
/// in the platform implementation. It's important to set the correct
331+
/// [MarkerType] so that the platform implementation can handle the markers:
332+
/// * If [MarkerType.advancedMarker] is used, all markers must be of type
333+
/// [AdvancedMarker].
334+
/// * If [MarkerType.marker] is used, markers cannot be of type
335+
/// [AdvancedMarker].
336+
///
337+
/// While some features work with either type, using the incorrect type
338+
/// may result in unexpected behavior.
328339
final MarkerType markerType;
329340

330341
/// Creates a [State] for this [GoogleMap].
@@ -358,7 +369,6 @@ class _GoogleMapState extends State<GoogleMap> {
358369
TextDirection.ltr,
359370
initialCameraPosition: widget.initialCameraPosition,
360371
gestureRecognizers: widget.gestureRecognizers,
361-
markerType: widget.markerType,
362372
),
363373
mapObjects: MapObjects(
364374
markers: widget.markers,

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

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,19 +3832,6 @@ public void setInitialClusterManagers(@NonNull List<PlatformClusterManager> sett
38323832
this.initialClusterManagers = setterArg;
38333833
}
38343834

3835-
private @NonNull PlatformMarkerType markerType;
3836-
3837-
public @NonNull PlatformMarkerType getMarkerType() {
3838-
return markerType;
3839-
}
3840-
3841-
public void setMarkerType(@NonNull PlatformMarkerType setterArg) {
3842-
if (setterArg == null) {
3843-
throw new IllegalStateException("Nonnull field \"markerType\" is null.");
3844-
}
3845-
this.markerType = setterArg;
3846-
}
3847-
38483835
/** Constructor is non-public to enforce null safety; use Builder. */
38493836
PlatformMapViewCreationParams() {}
38503837

@@ -3853,12 +3840,12 @@ public boolean equals(Object o) {
38533840
if (this == o) { return true; }
38543841
if (o == null || getClass() != o.getClass()) { return false; }
38553842
PlatformMapViewCreationParams that = (PlatformMapViewCreationParams) o;
3856-
return initialCameraPosition.equals(that.initialCameraPosition) && mapConfiguration.equals(that.mapConfiguration) && initialCircles.equals(that.initialCircles) && initialMarkers.equals(that.initialMarkers) && initialPolygons.equals(that.initialPolygons) && initialPolylines.equals(that.initialPolylines) && initialHeatmaps.equals(that.initialHeatmaps) && initialTileOverlays.equals(that.initialTileOverlays) && initialClusterManagers.equals(that.initialClusterManagers) && markerType.equals(that.markerType);
3843+
return initialCameraPosition.equals(that.initialCameraPosition) && mapConfiguration.equals(that.mapConfiguration) && initialCircles.equals(that.initialCircles) && initialMarkers.equals(that.initialMarkers) && initialPolygons.equals(that.initialPolygons) && initialPolylines.equals(that.initialPolylines) && initialHeatmaps.equals(that.initialHeatmaps) && initialTileOverlays.equals(that.initialTileOverlays) && initialClusterManagers.equals(that.initialClusterManagers);
38573844
}
38583845

38593846
@Override
38603847
public int hashCode() {
3861-
return Objects.hash(initialCameraPosition, mapConfiguration, initialCircles, initialMarkers, initialPolygons, initialPolylines, initialHeatmaps, initialTileOverlays, initialClusterManagers, markerType);
3848+
return Objects.hash(initialCameraPosition, mapConfiguration, initialCircles, initialMarkers, initialPolygons, initialPolylines, initialHeatmaps, initialTileOverlays, initialClusterManagers);
38623849
}
38633850

38643851
public static final class Builder {
@@ -3935,14 +3922,6 @@ public static final class Builder {
39353922
return this;
39363923
}
39373924

3938-
private @Nullable PlatformMarkerType markerType;
3939-
3940-
@CanIgnoreReturnValue
3941-
public @NonNull Builder setMarkerType(@NonNull PlatformMarkerType setterArg) {
3942-
this.markerType = setterArg;
3943-
return this;
3944-
}
3945-
39463925
public @NonNull PlatformMapViewCreationParams build() {
39473926
PlatformMapViewCreationParams pigeonReturn = new PlatformMapViewCreationParams();
39483927
pigeonReturn.setInitialCameraPosition(initialCameraPosition);
@@ -3954,14 +3933,13 @@ public static final class Builder {
39543933
pigeonReturn.setInitialHeatmaps(initialHeatmaps);
39553934
pigeonReturn.setInitialTileOverlays(initialTileOverlays);
39563935
pigeonReturn.setInitialClusterManagers(initialClusterManagers);
3957-
pigeonReturn.setMarkerType(markerType);
39583936
return pigeonReturn;
39593937
}
39603938
}
39613939

39623940
@NonNull
39633941
ArrayList<Object> toList() {
3964-
ArrayList<Object> toListResult = new ArrayList<>(10);
3942+
ArrayList<Object> toListResult = new ArrayList<>(9);
39653943
toListResult.add(initialCameraPosition);
39663944
toListResult.add(mapConfiguration);
39673945
toListResult.add(initialCircles);
@@ -3971,7 +3949,6 @@ ArrayList<Object> toList() {
39713949
toListResult.add(initialHeatmaps);
39723950
toListResult.add(initialTileOverlays);
39733951
toListResult.add(initialClusterManagers);
3974-
toListResult.add(markerType);
39753952
return toListResult;
39763953
}
39773954

@@ -3995,8 +3972,6 @@ ArrayList<Object> toList() {
39953972
pigeonResult.setInitialTileOverlays((List<PlatformTileOverlay>) initialTileOverlays);
39963973
Object initialClusterManagers = pigeonVar_list.get(8);
39973974
pigeonResult.setInitialClusterManagers((List<PlatformClusterManager>) initialClusterManagers);
3998-
Object markerType = pigeonVar_list.get(9);
3999-
pigeonResult.setMarkerType((PlatformMarkerType) markerType);
40003975
return pigeonResult;
40013976
}
40023977
}
@@ -4187,6 +4162,16 @@ public void setLiteModeEnabled(@Nullable Boolean setterArg) {
41874162
this.liteModeEnabled = setterArg;
41884163
}
41894164

4165+
private @Nullable PlatformMarkerType markerType;
4166+
4167+
public @Nullable PlatformMarkerType getMarkerType() {
4168+
return markerType;
4169+
}
4170+
4171+
public void setMarkerType(@Nullable PlatformMarkerType setterArg) {
4172+
this.markerType = setterArg;
4173+
}
4174+
41904175
private @Nullable String mapId;
41914176

41924177
public @Nullable String getMapId() {
@@ -4212,12 +4197,12 @@ public boolean equals(Object o) {
42124197
if (this == o) { return true; }
42134198
if (o == null || getClass() != o.getClass()) { return false; }
42144199
PlatformMapConfiguration that = (PlatformMapConfiguration) o;
4215-
return Objects.equals(compassEnabled, that.compassEnabled) && Objects.equals(cameraTargetBounds, that.cameraTargetBounds) && Objects.equals(mapType, that.mapType) && Objects.equals(minMaxZoomPreference, that.minMaxZoomPreference) && Objects.equals(mapToolbarEnabled, that.mapToolbarEnabled) && Objects.equals(rotateGesturesEnabled, that.rotateGesturesEnabled) && Objects.equals(scrollGesturesEnabled, that.scrollGesturesEnabled) && Objects.equals(tiltGesturesEnabled, that.tiltGesturesEnabled) && Objects.equals(trackCameraPosition, that.trackCameraPosition) && Objects.equals(zoomControlsEnabled, that.zoomControlsEnabled) && Objects.equals(zoomGesturesEnabled, that.zoomGesturesEnabled) && Objects.equals(myLocationEnabled, that.myLocationEnabled) && Objects.equals(myLocationButtonEnabled, that.myLocationButtonEnabled) && Objects.equals(padding, that.padding) && Objects.equals(indoorViewEnabled, that.indoorViewEnabled) && Objects.equals(trafficEnabled, that.trafficEnabled) && Objects.equals(buildingsEnabled, that.buildingsEnabled) && Objects.equals(liteModeEnabled, that.liteModeEnabled) && Objects.equals(mapId, that.mapId) && Objects.equals(style, that.style);
4200+
return Objects.equals(compassEnabled, that.compassEnabled) && Objects.equals(cameraTargetBounds, that.cameraTargetBounds) && Objects.equals(mapType, that.mapType) && Objects.equals(minMaxZoomPreference, that.minMaxZoomPreference) && Objects.equals(mapToolbarEnabled, that.mapToolbarEnabled) && Objects.equals(rotateGesturesEnabled, that.rotateGesturesEnabled) && Objects.equals(scrollGesturesEnabled, that.scrollGesturesEnabled) && Objects.equals(tiltGesturesEnabled, that.tiltGesturesEnabled) && Objects.equals(trackCameraPosition, that.trackCameraPosition) && Objects.equals(zoomControlsEnabled, that.zoomControlsEnabled) && Objects.equals(zoomGesturesEnabled, that.zoomGesturesEnabled) && Objects.equals(myLocationEnabled, that.myLocationEnabled) && Objects.equals(myLocationButtonEnabled, that.myLocationButtonEnabled) && Objects.equals(padding, that.padding) && Objects.equals(indoorViewEnabled, that.indoorViewEnabled) && Objects.equals(trafficEnabled, that.trafficEnabled) && Objects.equals(buildingsEnabled, that.buildingsEnabled) && Objects.equals(liteModeEnabled, that.liteModeEnabled) && Objects.equals(markerType, that.markerType) && Objects.equals(mapId, that.mapId) && Objects.equals(style, that.style);
42164201
}
42174202

42184203
@Override
42194204
public int hashCode() {
4220-
return Objects.hash(compassEnabled, cameraTargetBounds, mapType, minMaxZoomPreference, mapToolbarEnabled, rotateGesturesEnabled, scrollGesturesEnabled, tiltGesturesEnabled, trackCameraPosition, zoomControlsEnabled, zoomGesturesEnabled, myLocationEnabled, myLocationButtonEnabled, padding, indoorViewEnabled, trafficEnabled, buildingsEnabled, liteModeEnabled, mapId, style);
4205+
return Objects.hash(compassEnabled, cameraTargetBounds, mapType, minMaxZoomPreference, mapToolbarEnabled, rotateGesturesEnabled, scrollGesturesEnabled, tiltGesturesEnabled, trackCameraPosition, zoomControlsEnabled, zoomGesturesEnabled, myLocationEnabled, myLocationButtonEnabled, padding, indoorViewEnabled, trafficEnabled, buildingsEnabled, liteModeEnabled, markerType, mapId, style);
42214206
}
42224207

42234208
public static final class Builder {
@@ -4366,6 +4351,14 @@ public static final class Builder {
43664351
return this;
43674352
}
43684353

4354+
private @Nullable PlatformMarkerType markerType;
4355+
4356+
@CanIgnoreReturnValue
4357+
public @NonNull Builder setMarkerType(@Nullable PlatformMarkerType setterArg) {
4358+
this.markerType = setterArg;
4359+
return this;
4360+
}
4361+
43694362
private @Nullable String mapId;
43704363

43714364
@CanIgnoreReturnValue
@@ -4402,6 +4395,7 @@ public static final class Builder {
44024395
pigeonReturn.setTrafficEnabled(trafficEnabled);
44034396
pigeonReturn.setBuildingsEnabled(buildingsEnabled);
44044397
pigeonReturn.setLiteModeEnabled(liteModeEnabled);
4398+
pigeonReturn.setMarkerType(markerType);
44054399
pigeonReturn.setMapId(mapId);
44064400
pigeonReturn.setStyle(style);
44074401
return pigeonReturn;
@@ -4410,7 +4404,7 @@ public static final class Builder {
44104404

44114405
@NonNull
44124406
ArrayList<Object> toList() {
4413-
ArrayList<Object> toListResult = new ArrayList<>(20);
4407+
ArrayList<Object> toListResult = new ArrayList<>(21);
44144408
toListResult.add(compassEnabled);
44154409
toListResult.add(cameraTargetBounds);
44164410
toListResult.add(mapType);
@@ -4429,6 +4423,7 @@ ArrayList<Object> toList() {
44294423
toListResult.add(trafficEnabled);
44304424
toListResult.add(buildingsEnabled);
44314425
toListResult.add(liteModeEnabled);
4426+
toListResult.add(markerType);
44324427
toListResult.add(mapId);
44334428
toListResult.add(style);
44344429
return toListResult;
@@ -4472,9 +4467,11 @@ ArrayList<Object> toList() {
44724467
pigeonResult.setBuildingsEnabled((Boolean) buildingsEnabled);
44734468
Object liteModeEnabled = pigeonVar_list.get(17);
44744469
pigeonResult.setLiteModeEnabled((Boolean) liteModeEnabled);
4475-
Object mapId = pigeonVar_list.get(18);
4470+
Object markerType = pigeonVar_list.get(18);
4471+
pigeonResult.setMarkerType((PlatformMarkerType) markerType);
4472+
Object mapId = pigeonVar_list.get(19);
44764473
pigeonResult.setMapId((String) mapId);
4477-
Object style = pigeonVar_list.get(19);
4474+
Object style = pigeonVar_list.get(20);
44784475
pigeonResult.setStyle((String) style);
44794476
return pigeonResult;
44804477
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ class _ExampleGoogleMapState extends State<ExampleGoogleMap> {
404404
TextDirection.ltr,
405405
initialCameraPosition: widget.initialCameraPosition,
406406
gestureRecognizers: widget.gestureRecognizers,
407-
markerType: widget.markerType,
408407
),
409408
mapObjects: MapObjects(
410409
markers: widget.markers,

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
509509
PlatformViewCreatedCallback onPlatformViewCreated, {
510510
required PlatformMapConfiguration mapConfiguration,
511511
required MapWidgetConfiguration widgetConfiguration,
512-
required MarkerType markerType,
513512
MapObjects mapObjects = const MapObjects(),
514513
}) {
515514
final PlatformMapViewCreationParams creationParams =
@@ -533,7 +532,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
533532
initialClusterManagers: mapObjects.clusterManagers
534533
.map(_platformClusterManagerFromClusterManager)
535534
.toList(),
536-
markerType: _platformMarkerTypeFromMarkerType(markerType),
537535
);
538536

539537
const String viewType = 'plugins.flutter.dev/google_maps_android';
@@ -598,7 +596,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
598596
mapObjects: mapObjects,
599597
mapConfiguration:
600598
_platformMapConfigurationFromMapConfiguration(mapConfiguration),
601-
markerType: widgetConfiguration.markerType,
602599
);
603600
}
604601

@@ -624,7 +621,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
624621
widgetConfiguration: MapWidgetConfiguration(
625622
initialCameraPosition: initialCameraPosition,
626623
textDirection: textDirection,
627-
markerType: markerType,
628624
),
629625
mapObjects: MapObjects(
630626
markers: markers,
@@ -634,7 +630,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
634630
clusterManagers: clusterManagers,
635631
tileOverlays: tileOverlays),
636632
mapConfiguration: _platformMapConfigurationFromOptionsJson(mapOptions),
637-
markerType: markerType,
638633
);
639634
}
640635

@@ -876,13 +871,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
876871
}
877872
}
878873

879-
PlatformMarkerType _platformMarkerTypeFromMarkerType(MarkerType markerType) {
880-
return switch (markerType) {
881-
MarkerType.marker => PlatformMarkerType.marker,
882-
MarkerType.advancedMarker => PlatformMarkerType.advancedMarker,
883-
};
884-
}
885-
886874
/// Convert [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon.
887875
@visibleForTesting
888876
static PlatformMapBitmapScaling platformMapBitmapScalingFromScaling(
@@ -1222,6 +1210,14 @@ PlatformEdgeInsets? _platformEdgeInsetsFromEdgeInsets(EdgeInsets? insets) {
12221210
right: insets.right);
12231211
}
12241212

1213+
PlatformMarkerType? _platformMarkerTypeFromMarkerType(MarkerType? markerType) {
1214+
return switch (markerType) {
1215+
null => null,
1216+
MarkerType.marker => PlatformMarkerType.marker,
1217+
MarkerType.advancedMarker => PlatformMarkerType.advancedMarker,
1218+
};
1219+
}
1220+
12251221
PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration(
12261222
MapConfiguration config) {
12271223
return PlatformMapConfiguration(
@@ -1245,6 +1241,7 @@ PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration(
12451241
trafficEnabled: config.trafficEnabled,
12461242
buildingsEnabled: config.buildingsEnabled,
12471243
liteModeEnabled: config.liteModeEnabled,
1244+
markerType: _platformMarkerTypeFromMarkerType(config.markerType),
12481245
mapId: config.mapId,
12491246
style: config.style,
12501247
);
@@ -1286,6 +1283,7 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson(
12861283
trafficEnabled: options['trafficEnabled'] as bool?,
12871284
buildingsEnabled: options['buildingsEnabled'] as bool?,
12881285
liteModeEnabled: options['liteModeEnabled'] as bool?,
1286+
markerType: _platformMarkerTypeFromIndex(options['markerType'] as int?),
12891287
mapId: options['mapId'] as String?,
12901288
style: options['style'] as String?,
12911289
);
@@ -1353,6 +1351,14 @@ PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson(
13531351
return PlatformZoomRange(min: minMaxZoom[0], max: minMaxZoom[1]);
13541352
}
13551353

1354+
PlatformMarkerType _platformMarkerTypeFromIndex(int? index) {
1355+
return switch (index) {
1356+
0 => PlatformMarkerType.marker,
1357+
1 => PlatformMarkerType.advancedMarker,
1358+
_ => PlatformMarkerType.marker,
1359+
};
1360+
}
1361+
13561362
/// Converts platform interface's JointType to Pigeon's PlatformJointType.
13571363
@visibleForTesting
13581364
PlatformJointType platformJointTypeFromJointType(JointType jointType) {

0 commit comments

Comments
 (0)