Skip to content

Commit 9f7f624

Browse files
committed
Remove isAdvanced flag from AdvancedMarker class
1 parent abed4b3 commit 9f7f624

File tree

10 files changed

+28
-23
lines changed

10 files changed

+28
-23
lines changed

packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const CameraPosition _kInitialCameraPosition = CameraPosition(
2121
target: _kInitialMapCenter,
2222
zoom: _kInitialZoomLevel,
2323
);
24-
const String _kCloudMapId = '000000000000000'; // Dummy map ID.
24+
const String _kMapId = '000000000000000'; // Dummy map ID.
2525

2626
// The tolerance value for floating-point comparisons in the tests.
2727
// This value was selected as the minimum possible value that the test passes.
@@ -1138,7 +1138,7 @@ void main() {
11381138
child: ExampleGoogleMap(
11391139
key: key,
11401140
initialCameraPosition: _kInitialCameraPosition,
1141-
cloudMapId: _kCloudMapId,
1141+
mapId: _kMapId,
11421142
),
11431143
));
11441144
});

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ class ExampleGoogleMap extends StatefulWidget {
272272
this.onTap,
273273
this.onLongPress,
274274
this.mapId,
275-
@Deprecated('cloudMapId is deprecated. Use mapId instead') this.cloudMapId,
276275
this.style,
277276
});
278277

@@ -382,13 +381,6 @@ class ExampleGoogleMap extends StatefulWidget {
382381
/// for more details.
383382
final String? mapId;
384383

385-
/// Identifier that's associated with a specific cloud-based map style.
386-
///
387-
/// See https://developers.google.com/maps/documentation/get-map-id
388-
/// for more details.
389-
@Deprecated('cloudMapId is deprecated. Use mapId instead')
390-
final String? cloudMapId;
391-
392384
/// The locally configured style for the map.
393385
final String? style;
394386

@@ -613,7 +605,7 @@ MapConfiguration _configurationFromMapWidget(ExampleGoogleMap map) {
613605
indoorViewEnabled: map.indoorViewEnabled,
614606
trafficEnabled: map.trafficEnabled,
615607
buildingsEnabled: map.buildingsEnabled,
616-
mapId: map.mapId ?? map.cloudMapId,
608+
mapId: map.mapId,
617609
style: map.style,
618610
);
619611
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class MapIdBodyState extends State<MapIdBody> {
5454
zoom: 7.0,
5555
),
5656
key: _key,
57-
cloudMapId: _mapId,
57+
mapId: _mapId,
5858
);
5959

6060
final List<Widget> columnChildren = <Widget>[

packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ - (instancetype)initWithMapView:(GMSMapView *_Nonnull)mapView
162162
NSString *pigeonSuffix = [NSString stringWithFormat:@"%lld", viewId];
163163
_dartCallbackHandler = [[FGMMapsCallbackApi alloc] initWithBinaryMessenger:registrar.messenger
164164
messageChannelSuffix:pigeonSuffix];
165+
FGMPlatformMarkerType markerType = creationParameters.markerType;
165166
_mapView.delegate = self;
166167
_mapView.paddingAdjustmentBehavior = kGMSMapViewPaddingAdjustmentBehaviorNever;
167168
_registrar = registrar;
@@ -171,7 +172,8 @@ - (instancetype)initWithMapView:(GMSMapView *_Nonnull)mapView
171172
_markersController = [[FLTMarkersController alloc] initWithMapView:_mapView
172173
callbackHandler:_dartCallbackHandler
173174
clusterManagersController:_clusterManagersController
174-
registrar:registrar];
175+
registrar:registrar
176+
markerType:markerType];
175177
_polygonsController = [[FLTPolygonsController alloc] initWithMapView:_mapView
176178
callbackHandler:_dartCallbackHandler
177179
registrar:registrar];

packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
2828
- (instancetype)initWithMapView:(GMSMapView *)mapView
2929
callbackHandler:(FGMMapsCallbackApi *)callbackHandler
3030
clusterManagersController:(nullable FGMClusterManagersController *)clusterManagersController
31-
registrar:(NSObject<FlutterPluginRegistrar> *)registrar;
31+
registrar:(NSObject<FlutterPluginRegistrar> *)registrar
32+
markerType:(FGMPlatformMarkerType)markerType;
3233
- (void)addMarkers:(NSArray<FGMPlatformMarker *> *)markersToAdd;
3334
- (void)changeMarkers:(NSArray<FGMPlatformMarker *> *)markersToChange;
3435
- (void)removeMarkersWithIdentifiers:(NSArray<NSString *> *)identifiers;

packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ @interface FLTMarkersController ()
147147
@property(weak, nonatomic, nullable) FGMClusterManagersController *clusterManagersController;
148148
@property(weak, nonatomic) NSObject<FlutterPluginRegistrar> *registrar;
149149
@property(weak, nonatomic) GMSMapView *mapView;
150+
@property(nonatomic) FGMPlatformMarkerType markerType;
150151

151152
@end
152153

@@ -155,14 +156,16 @@ @implementation FLTMarkersController
155156
- (instancetype)initWithMapView:(GMSMapView *)mapView
156157
callbackHandler:(FGMMapsCallbackApi *)callbackHandler
157158
clusterManagersController:(nullable FGMClusterManagersController *)clusterManagersController
158-
registrar:(NSObject<FlutterPluginRegistrar> *)registrar {
159+
registrar:(NSObject<FlutterPluginRegistrar> *)registrar
160+
markerType:(FGMPlatformMarkerType)markerType {
159161
self = [super init];
160162
if (self) {
161163
_callbackHandler = callbackHandler;
162164
_mapView = mapView;
163165
_clusterManagersController = clusterManagersController;
164166
_markerIdentifierToController = [[NSMutableDictionary alloc] init];
165167
_registrar = registrar;
168+
_markerType = markerType;
166169
}
167170
return self;
168171
}
@@ -177,9 +180,9 @@ - (void)addMarker:(FGMPlatformMarker *)markerToAdd {
177180
CLLocationCoordinate2D position = FGMGetCoordinateForPigeonLatLng(markerToAdd.position);
178181
NSString *markerIdentifier = markerToAdd.markerId;
179182
NSString *clusterManagerIdentifier = markerToAdd.clusterManagerId;
180-
NSNumber *isAdvanced = markerToAdd[@"isAdvanced"];
181-
GMSMarker *marker = isAdvanced ? [GMSAdvancedMarker markerWithPosition:position]
182-
: [GMSMarker markerWithPosition:position];
183+
GMSMarker *marker = (self.markerType == FGMPlatformMarkerTypeAdvanced)
184+
? [GMSAdvancedMarker markerWithPosition:position]
185+
: [GMSMarker markerWithPosition:position];
183186

184187
FLTGoogleMapMarkerController *controller =
185188
[[FLTGoogleMapMarkerController alloc] initWithMarker:marker

packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform {
524524
initialGroundOverlays: mapObjects.groundOverlays
525525
.map(_platformGroundOverlayFromGroundOverlay)
526526
.toList(),
527+
markerType:
528+
_platformMarkerTypeFromMarkerType(widgetConfiguration.markerType),
527529
);
528530

529531
return UiKitView(
@@ -773,6 +775,14 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform {
773775
identifier: clusterManager.clusterManagerId.value);
774776
}
775777

778+
static PlatformMarkerType _platformMarkerTypeFromMarkerType(
779+
MarkerType markerType) {
780+
return switch (markerType) {
781+
MarkerType.legacy => PlatformMarkerType.legacy,
782+
MarkerType.advanced => PlatformMarkerType.advanced,
783+
};
784+
}
785+
776786
static PlatformCameraUpdate _platformCameraUpdateFromCameraUpdate(
777787
CameraUpdate update) {
778788
switch (update.updateType) {

packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ class PlatformMapViewCreationParams {
399399
required this.initialTileOverlays,
400400
required this.initialClusterManagers,
401401
required this.initialGroundOverlays,
402+
required this.markerType,
402403
});
403404

404405
final PlatformCameraPosition initialCameraPosition;

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
556556
'circlesToAdd': serializeCircleSet(mapObjects.circles),
557557
'heatmapsToAdd': serializeHeatmapSet(mapObjects.heatmaps),
558558
'tileOverlaysToAdd': serializeTileOverlaySet(mapObjects.tileOverlays),
559+
'markerType': widgetConfiguration.markerType.index,
559560
};
560561

561562
if (defaultTargetPlatform == TargetPlatform.android) {

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ class AdvancedMarker extends Marker {
109109
}
110110
}
111111

112-
// Add a flag indicating that this is an advanced marker. This might be used
113-
// by platform implementations to distinguish between legacy and advanced
114-
// markers
115-
addIfPresent('isAdvanced', true);
116-
117112
addIfPresent('markerId', markerId.value);
118113
addIfPresent('alpha', alpha);
119114
addIfPresent('anchor', offsetToJson(anchor));

0 commit comments

Comments
 (0)