Skip to content

Commit cde0ca1

Browse files
committed
Remove isAdvanced flag from AdvancedMarker on Android
1 parent 9f7f624 commit cde0ca1

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.google.android.gms.maps.model.CameraPosition;
1313
import com.google.android.gms.maps.model.LatLngBounds;
1414
import io.flutter.plugin.common.BinaryMessenger;
15+
import io.flutter.plugins.googlemaps.Messages.PlatformMarkerType;
1516
import java.util.List;
1617

1718
class GoogleMapBuilder implements GoogleMapOptionsSink {
@@ -37,9 +38,11 @@ GoogleMapController build(
3738
int id,
3839
Context context,
3940
BinaryMessenger binaryMessenger,
40-
LifecycleProvider lifecycleProvider) {
41+
LifecycleProvider lifecycleProvider,
42+
PlatformMarkerType markerType) {
4143
final GoogleMapController controller =
42-
new GoogleMapController(id, context, binaryMessenger, lifecycleProvider, options);
44+
new GoogleMapController(id, context, binaryMessenger, lifecycleProvider, options,
45+
markerType);
4346
controller.init();
4447
controller.setMyLocationEnabled(myLocationEnabled);
4548
controller.setMyLocationButtonEnabled(myLocationButtonEnabled);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import io.flutter.plugins.googlemaps.Messages.MapsApi;
5252
import io.flutter.plugins.googlemaps.Messages.MapsCallbackApi;
5353
import io.flutter.plugins.googlemaps.Messages.MapsInspectorApi;
54+
import io.flutter.plugins.googlemaps.Messages.PlatformMarkerType;
5455
import java.io.ByteArrayOutputStream;
5556
import java.util.ArrayList;
5657
import java.util.List;
@@ -117,7 +118,8 @@ class GoogleMapController
117118
Context context,
118119
BinaryMessenger binaryMessenger,
119120
LifecycleProvider lifecycleProvider,
120-
GoogleMapOptions options) {
121+
GoogleMapOptions options,
122+
PlatformMarkerType markerType) {
121123
this.id = id;
122124
this.context = context;
123125
this.options = options;
@@ -136,7 +138,8 @@ class GoogleMapController
136138
clusterManagersController,
137139
assetManager,
138140
density,
139-
new Convert.BitmapDescriptorFactoryWrapper());
141+
new Convert.BitmapDescriptorFactoryWrapper(),
142+
markerType);
140143
this.polygonsController = new PolygonsController(flutterApi, density);
141144
this.polylinesController = new PolylinesController(flutterApi, assetManager, density);
142145
this.circlesController = new CirclesController(flutterApi, density);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public PlatformView create(@NonNull Context context, int id, @Nullable Object ar
5353
builder.setMapId(mapId);
5454
}
5555

56-
return builder.build(id, context, binaryMessenger, lifecycleProvider);
56+
return builder.build(id, context, binaryMessenger, lifecycleProvider, params.getMarkerType());
5757
}
5858
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.google.android.gms.maps.model.MarkerOptions;
1414
import com.google.maps.android.collections.MarkerManager;
1515
import io.flutter.plugins.googlemaps.Messages.MapsCallbackApi;
16+
import io.flutter.plugins.googlemaps.Messages.PlatformMarkerType;
1617
import java.util.HashMap;
1718
import java.util.List;
1819
import java.util.Objects;
@@ -27,13 +28,15 @@ class MarkersController {
2728
private final AssetManager assetManager;
2829
private final float density;
2930
private final Convert.BitmapDescriptorFactoryWrapper bitmapDescriptorFactoryWrapper;
31+
private PlatformMarkerType markerType;
3032

3133
MarkersController(
3234
@NonNull MapsCallbackApi flutterApi,
3335
ClusterManagersController clusterManagersController,
3436
AssetManager assetManager,
3537
float density,
36-
Convert.BitmapDescriptorFactoryWrapper bitmapDescriptorFactoryWrapper) {
38+
Convert.BitmapDescriptorFactoryWrapper bitmapDescriptorFactoryWrapper,
39+
@NonNull PlatformMarkerType markerType) {
3740
this.markerIdToMarkerBuilder = new HashMap<>();
3841
this.markerIdToController = new HashMap<>();
3942
this.googleMapsMarkerIdToDartMarkerId = new HashMap<>();
@@ -42,6 +45,7 @@ class MarkersController {
4245
this.assetManager = assetManager;
4346
this.density = density;
4447
this.bitmapDescriptorFactoryWrapper = bitmapDescriptorFactoryWrapper;
48+
this.markerType = markerType;
4549
}
4650

4751
void setCollection(MarkerManager.Collection markerCollection) {
@@ -176,8 +180,9 @@ public void onClusterItemRendered(MarkerBuilder markerBuilder, Marker marker) {
176180
private void addMarker(@NonNull Messages.PlatformMarker marker) {
177181
String markerId = marker.getMarkerId();
178182
String clusterManagerId = marker.getClusterManagerId();
183+
boolean isAdvancedMarker = markerType == PlatformMarkerType.ADVANCED;
179184
MarkerBuilder markerBuilder = new MarkerBuilder(markerId, clusterManagerId,
180-
marker.getIsAdvanced());
185+
isAdvancedMarker);
181186
Convert.interpretMarkerOptions(
182187
marker, markerBuilder, assetManager, density, bitmapDescriptorFactoryWrapper);
183188
addMarker(markerBuilder);

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
550550
PlatformViewCreatedCallback onPlatformViewCreated, {
551551
required PlatformMapConfiguration mapConfiguration,
552552
required MapWidgetConfiguration widgetConfiguration,
553+
required MarkerType markerType,
553554
MapObjects mapObjects = const MapObjects(),
554-
MarkerType markerType = MarkerType.legacy,
555555
}) {
556556
assert(
557557
mapObjects.groundOverlays.every((GroundOverlay groundOverlay) =>
@@ -582,6 +582,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
582582
initialGroundOverlays: mapObjects.groundOverlays
583583
.map(_platformGroundOverlayFromGroundOverlay)
584584
.toList(),
585+
markerType: _platformMarkerTypeFromMarkerType(markerType),
585586
);
586587

587588
const String viewType = 'plugins.flutter.dev/google_maps_android';
@@ -638,7 +639,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
638639
required MapWidgetConfiguration widgetConfiguration,
639640
MapConfiguration mapConfiguration = const MapConfiguration(),
640641
MapObjects mapObjects = const MapObjects(),
641-
MarkerType markerType = MarkerType.legacy,
642642
}) {
643643
return _buildView(
644644
creationId,
@@ -647,6 +647,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
647647
mapObjects: mapObjects,
648648
mapConfiguration:
649649
_platformMapConfigurationFromMapConfiguration(mapConfiguration),
650+
markerType: widgetConfiguration.markerType,
650651
);
651652
}
652653

@@ -808,9 +809,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
808809
zIndex: marker.zIndex,
809810
markerId: marker.markerId.value,
810811
clusterManagerId: marker.clusterManagerId?.value,
811-
isAdvanced: marker is AdvancedMarker,
812812
collisionBehavior: marker is AdvancedMarker
813-
? _platformMarkerCollisionBehaviorFromMarkerCollisionBehavior(
813+
? platformMarkerCollisionBehaviorFromMarkerCollisionBehavior(
814814
marker.collisionBehavior,
815815
)
816816
: PlatformMarkerCollisionBehavior.required,
@@ -947,6 +947,13 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
947947
}
948948
}
949949

950+
PlatformMarkerType _platformMarkerTypeFromMarkerType(MarkerType markerType) {
951+
return switch (markerType) {
952+
MarkerType.legacy => PlatformMarkerType.legacy,
953+
MarkerType.advanced => PlatformMarkerType.advanced,
954+
};
955+
}
956+
950957
/// Convert [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon.
951958
@visibleForTesting
952959
static PlatformMapBitmapScaling platformMapBitmapScalingFromScaling(
@@ -1439,9 +1446,11 @@ PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) {
14391446
return PlatformPatternItem(type: PlatformPatternItemType.dot);
14401447
}
14411448

1449+
/// Converts a MarkerCollisionBehavior to Pigeon's
1450+
/// PlatformMarkerCollisionBehavior
14421451
@visibleForTesting
14431452
PlatformMarkerCollisionBehavior
1444-
_platformMarkerCollisionBehaviorFromMarkerCollisionBehavior(
1453+
platformMarkerCollisionBehaviorFromMarkerCollisionBehavior(
14451454
MarkerCollisionBehavior markerCollisionBehavior,
14461455
) {
14471456
switch (markerCollisionBehavior) {

packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ class PlatformMarker {
202202
final String markerId;
203203
final String? clusterManagerId;
204204

205-
final bool isAdvanced;
206205
final PlatformMarkerCollisionBehavior collisionBehavior;
207206
}
208207

@@ -449,6 +448,7 @@ class PlatformMapViewCreationParams {
449448
required this.initialTileOverlays,
450449
required this.initialClusterManagers,
451450
required this.initialGroundOverlays,
451+
required this.markerType,
452452
});
453453

454454
final PlatformCameraPosition initialCameraPosition;
@@ -461,6 +461,12 @@ class PlatformMapViewCreationParams {
461461
final List<PlatformTileOverlay> initialTileOverlays;
462462
final List<PlatformClusterManager> initialClusterManagers;
463463
final List<PlatformGroundOverlay> initialGroundOverlays;
464+
final PlatformMarkerType markerType;
465+
}
466+
467+
enum PlatformMarkerType {
468+
legacy,
469+
advanced,
464470
}
465471

466472
/// Pigeon equivalent of MapConfiguration.

0 commit comments

Comments
 (0)