Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.19.1

* Fixes a regression in 2.19.0 that caused crashes when adding markers.

## 2.19.0

* Adds support for advanced markers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GoogleMapController build(
Context context,
BinaryMessenger binaryMessenger,
LifecycleProvider lifecycleProvider,
PlatformMarkerType markerType) {
@NonNull PlatformMarkerType markerType) {
final GoogleMapController controller =
new GoogleMapController(
id, context, binaryMessenger, lifecycleProvider, options, markerType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class GoogleMapController
BinaryMessenger binaryMessenger,
LifecycleProvider lifecycleProvider,
GoogleMapOptions options,
PlatformMarkerType markerType) {
@NonNull PlatformMarkerType markerType) {
this.id = id;
this.context = context;
this.options = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugins.googlemaps;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.maps.model.AdvancedMarkerOptions;
import com.google.android.gms.maps.model.BitmapDescriptor;
Expand All @@ -19,7 +20,7 @@ class MarkerBuilder implements MarkerOptionsSink, ClusterItem {
private String markerId;
private boolean consumeTapEvents;

MarkerBuilder(String markerId, String clusterManagerId, PlatformMarkerType markerType) {
MarkerBuilder(String markerId, String clusterManagerId, @NonNull PlatformMarkerType markerType) {
switch (markerType) {
case ADVANCED_MARKER:
this.advancedMarkerOptions = new AdvancedMarkerOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MarkersController {
private final AssetManager assetManager;
private final float density;
private final Convert.BitmapDescriptorFactoryWrapper bitmapDescriptorFactoryWrapper;
private PlatformMarkerType markerType;
private @NonNull PlatformMarkerType markerType;

MarkersController(
@NonNull MapsCallbackApi flutterApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5201,13 +5201,16 @@ public void setLiteModeEnabled(@Nullable Boolean setterArg) {
this.liteModeEnabled = setterArg;
}

private @Nullable PlatformMarkerType markerType;
private @NonNull PlatformMarkerType markerType;

public @Nullable PlatformMarkerType getMarkerType() {
public @NonNull PlatformMarkerType getMarkerType() {
return markerType;
}

public void setMarkerType(@Nullable PlatformMarkerType setterArg) {
public void setMarkerType(@NonNull PlatformMarkerType setterArg) {
if (setterArg == null) {
throw new IllegalStateException("Nonnull field \"markerType\" is null.");
}
this.markerType = setterArg;
}

Expand All @@ -5231,6 +5234,9 @@ public void setStyle(@Nullable String setterArg) {
this.style = setterArg;
}

/** Constructor is non-public to enforce null safety; use Builder. */
PlatformMapConfiguration() {}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -5258,7 +5264,7 @@ public boolean equals(Object o) {
&& Objects.equals(trafficEnabled, that.trafficEnabled)
&& Objects.equals(buildingsEnabled, that.buildingsEnabled)
&& Objects.equals(liteModeEnabled, that.liteModeEnabled)
&& Objects.equals(markerType, that.markerType)
&& markerType.equals(that.markerType)
&& Objects.equals(mapId, that.mapId)
&& Objects.equals(style, that.style);
}
Expand Down Expand Up @@ -5439,7 +5445,7 @@ public static final class Builder {
private @Nullable PlatformMarkerType markerType;

@CanIgnoreReturnValue
public @NonNull Builder setMarkerType(@Nullable PlatformMarkerType setterArg) {
public @NonNull Builder setMarkerType(@NonNull PlatformMarkerType setterArg) {
this.markerType = setterArg;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,138 +381,142 @@ public void GetPinConfigFromPlatformPinConfig_GlyphBitmap() {
Assert.assertEquals(mockBitmapDescriptor, pinConfig.getGlyph().getBitmapDescriptor());
}

/// Returns a PlatformMapConfiguration.Builder that sets required parameters.
private Messages.PlatformMapConfiguration.Builder getMinimalConfigurationBuilder() {
return new Messages.PlatformMapConfiguration.Builder().setMarkerType(PlatformMarkerType.MARKER);
}

@Test
public void interpretMapConfiguration_handlesNulls() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().build();
final Messages.PlatformMapConfiguration config = getMinimalConfigurationBuilder().build();
Convert.interpretMapConfiguration(config, optionsSink);
verifyNoInteractions(optionsSink);
}

@Test
public void interpretMapConfiguration_handlesCompassEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setCompassEnabled(false).build();
getMinimalConfigurationBuilder().setCompassEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setCompassEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesMapToolbarEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setMapToolbarEnabled(true).build();
getMinimalConfigurationBuilder().setMapToolbarEnabled(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setMapToolbarEnabled(true);
}

@Test
public void interpretMapConfiguration_handlesRotateGesturesEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setRotateGesturesEnabled(false).build();
getMinimalConfigurationBuilder().setRotateGesturesEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setRotateGesturesEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesScrollGesturesEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setScrollGesturesEnabled(true).build();
getMinimalConfigurationBuilder().setScrollGesturesEnabled(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setScrollGesturesEnabled(true);
}

@Test
public void interpretMapConfiguration_handlesTiltGesturesEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setTiltGesturesEnabled(false).build();
getMinimalConfigurationBuilder().setTiltGesturesEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setTiltGesturesEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesTrackCameraPosition() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setTrackCameraPosition(true).build();
getMinimalConfigurationBuilder().setTrackCameraPosition(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setTrackCameraPosition(true);
}

@Test
public void interpretMapConfiguration_handlesZoomControlsEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setZoomControlsEnabled(false).build();
getMinimalConfigurationBuilder().setZoomControlsEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setZoomControlsEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesZoomGesturesEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setZoomGesturesEnabled(true).build();
getMinimalConfigurationBuilder().setZoomGesturesEnabled(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setZoomGesturesEnabled(true);
}

@Test
public void interpretMapConfiguration_handlesMyLocationEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setMyLocationEnabled(false).build();
getMinimalConfigurationBuilder().setMyLocationEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setMyLocationEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesMyLocationButtonEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setMyLocationButtonEnabled(true).build();
getMinimalConfigurationBuilder().setMyLocationButtonEnabled(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setMyLocationButtonEnabled(true);
}

@Test
public void interpretMapConfiguration_handlesIndoorViewEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setIndoorViewEnabled(false).build();
getMinimalConfigurationBuilder().setIndoorViewEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setIndoorEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesTrafficEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setTrafficEnabled(true).build();
getMinimalConfigurationBuilder().setTrafficEnabled(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setTrafficEnabled(true);
}

@Test
public void interpretMapConfiguration_handlesBuildingsEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setBuildingsEnabled(false).build();
getMinimalConfigurationBuilder().setBuildingsEnabled(false).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setBuildingsEnabled(false);
}

@Test
public void interpretMapConfiguration_handlesLiteModeEnabled() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setLiteModeEnabled(true).build();
getMinimalConfigurationBuilder().setLiteModeEnabled(true).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setLiteModeEnabled(true);
}

@Test
public void interpretMapConfiguration_handlesStyle() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder().setStyle("foo").build();
getMinimalConfigurationBuilder().setStyle("foo").build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setMapStyle("foo");
}

@Test
public void interpretMapConfiguration_handlesUnboundedCameraTargetBounds() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder()
getMinimalConfigurationBuilder()
.setCameraTargetBounds(new Messages.PlatformCameraTargetBounds.Builder().build())
.build();
Convert.interpretMapConfiguration(config, optionsSink);
Expand All @@ -523,7 +527,7 @@ public void interpretMapConfiguration_handlesUnboundedCameraTargetBounds() {
public void interpretMapConfiguration_handlesBoundedCameraTargetBounds() {
LatLngBounds bounds = new LatLngBounds(new LatLng(10, 20), new LatLng(30, 40));
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder()
getMinimalConfigurationBuilder()
.setCameraTargetBounds(
new Messages.PlatformCameraTargetBounds.Builder()
.setBounds(
Expand All @@ -548,9 +552,7 @@ public void interpretMapConfiguration_handlesBoundedCameraTargetBounds() {
@Test
public void interpretMapConfiguration_handlesMapType() {
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder()
.setMapType(Messages.PlatformMapType.HYBRID)
.build();
getMinimalConfigurationBuilder().setMapType(Messages.PlatformMapType.HYBRID).build();
Convert.interpretMapConfiguration(config, optionsSink);
verify(optionsSink, times(1)).setMapType(MAP_TYPE_HYBRID);
}
Expand All @@ -562,7 +564,7 @@ public void interpretMapConfiguration_handlesPadding() {
final double left = 3.0;
final double right = 4.0;
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder()
getMinimalConfigurationBuilder()
.setPadding(
new Messages.PlatformEdgeInsets.Builder()
.setTop(top)
Expand All @@ -581,7 +583,7 @@ public void interpretMapConfiguration_handlesMinMaxZoomPreference() {
final double min = 1.0;
final double max = 2.0;
final Messages.PlatformMapConfiguration config =
new Messages.PlatformMapConfiguration.Builder()
getMinimalConfigurationBuilder()
.setMinMaxZoomPreference(
new Messages.PlatformZoomRange.Builder().setMin(min).setMax(max).build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1421,9 +1421,8 @@ PlatformEdgeInsets? _platformEdgeInsetsFromEdgeInsets(EdgeInsets? insets) {
);
}

PlatformMarkerType? _platformMarkerTypeFromMarkerType(MarkerType? markerType) {
PlatformMarkerType _platformMarkerTypeFromMarkerType(MarkerType markerType) {
return switch (markerType) {
null => null,
MarkerType.marker => PlatformMarkerType.marker,
MarkerType.advancedMarker => PlatformMarkerType.advancedMarker,
};
Expand Down Expand Up @@ -1455,7 +1454,9 @@ PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration(
trafficEnabled: config.trafficEnabled,
buildingsEnabled: config.buildingsEnabled,
liteModeEnabled: config.liteModeEnabled,
markerType: _platformMarkerTypeFromMarkerType(config.markerType),
markerType: _platformMarkerTypeFromMarkerType(
config.markerType ?? MarkerType.marker,
),
mapId: config.mapId,
style: config.style,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ class PlatformMapConfiguration {
this.trafficEnabled,
this.buildingsEnabled,
this.liteModeEnabled,
this.markerType,
required this.markerType,
this.mapId,
this.style,
});
Expand Down Expand Up @@ -1853,7 +1853,7 @@ class PlatformMapConfiguration {

bool? liteModeEnabled;

PlatformMarkerType? markerType;
PlatformMarkerType markerType;

String? mapId;

Expand Down Expand Up @@ -1910,7 +1910,7 @@ class PlatformMapConfiguration {
trafficEnabled: result[15] as bool?,
buildingsEnabled: result[16] as bool?,
liteModeEnabled: result[17] as bool?,
markerType: result[18] as PlatformMarkerType?,
markerType: result[18]! as PlatformMarkerType,
mapId: result[19] as String?,
style: result[20] as String?,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class PlatformMapConfiguration {
final bool? trafficEnabled;
final bool? buildingsEnabled;
final bool? liteModeEnabled;
final PlatformMarkerType? markerType;
final PlatformMarkerType markerType;
final String? mapId;
final String? style;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_android
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.19.0
version: 2.19.1

environment:
sdk: ^3.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1651,4 +1651,26 @@ void main() {
PlatformMarkerType.marker,
);
});

test('marker type defaults to legacy if unset', () async {
final maps = GoogleMapsFlutterAndroid();
final Widget widget = maps.buildViewWithConfiguration(
1,
(int _) {},
widgetConfiguration: const MapWidgetConfiguration(
initialCameraPosition: CameraPosition(target: LatLng(0, 0), zoom: 1),
textDirection: TextDirection.ltr,
),
);

expect(widget, isA<AndroidView>());
final dynamic creationParams = (widget as AndroidView).creationParams;
expect(creationParams, isA<PlatformMapViewCreationParams>());
expect(
(creationParams as PlatformMapViewCreationParams)
.mapConfiguration
.markerType,
PlatformMarkerType.marker,
);
});
}
Loading