diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 2333f7d16028..cd6ab24c83ab 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.4.0+4 +* Allows marker position updates. Issue [#83467](https://github.com/flutter/flutter/issues/83467). * Updates code for `no_leading_underscores_for_local_identifiers` lint. ## 0.4.0+3 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 6591b0ca08d7..2e2d77b71dec 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -100,13 +100,16 @@ void main() { testWidgets('update', (WidgetTester tester) async { final MarkerController controller = MarkerController(marker: marker); final gmaps.MarkerOptions options = gmaps.MarkerOptions() - ..draggable = true; + ..draggable = true + ..position = gmaps.LatLng(42, 54); expect(marker.draggable, isNull); controller.update(options); expect(marker.draggable, isTrue); + expect(marker.position?.lat, equals(42)); + expect(marker.position?.lng, equals(54)); }); testWidgets('infoWindow null, showInfoWindow.', diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart index e4c4dd7c0cfe..62d4971e05c3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart @@ -55,15 +55,22 @@ void main() { expect( controller.markers[const MarkerId('1')]?.marker?.draggable, isFalse); - // Update the marker with radius 10 + // Update the marker with draggability and position final Set updatedMarkers = { - const Marker(markerId: MarkerId('1'), draggable: true), + const Marker( + markerId: MarkerId('1'), + draggable: true, + position: LatLng(42, 54), + ), }; controller.changeMarkers(updatedMarkers); expect(controller.markers.length, 1); - expect( - controller.markers[const MarkerId('1')]?.marker?.draggable, isTrue); + final gmaps.Marker? marker = + controller.markers[const MarkerId('1')]?.marker; + expect(marker?.draggable, isTrue); + expect(marker?.position?.lat, equals(42)); + expect(marker?.position?.lng, equals(54)); }); testWidgets('removeMarkers', (WidgetTester tester) async { diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 2b09950cc00d..b0b5c801d067 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -284,17 +284,15 @@ gmaps.Icon? _gmIconFromBitmapDescriptor(BitmapDescriptor bitmapDescriptor) { // Computes the options for a new [gmaps.Marker] from an incoming set of options // [marker], and the existing marker registered with the map: [currentMarker]. -// Preserves the position from the [currentMarker], if set. gmaps.MarkerOptions _markerOptionsFromMarker( Marker marker, gmaps.Marker? currentMarker, ) { return gmaps.MarkerOptions() - ..position = currentMarker?.position ?? - gmaps.LatLng( - marker.position.latitude, - marker.position.longitude, - ) + ..position = gmaps.LatLng( + marker.position.latitude, + marker.position.longitude, + ) ..title = sanitizeHtml(marker.infoWindow.title ?? '') ..zIndex = marker.zIndex ..visible = marker.visible diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 572d9110be8e..6278ab01ba6c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_web description: Web platform implementation of google_maps_flutter repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 0.4.0+3 +version: 0.4.0+4 environment: sdk: ">=2.12.0 <3.0.0"