[google_maps_flutter_web] Allow marker position updates (#3697)

Unconditionally convert the current marker position in `convert.dart:_markerOptionsFromMarker`, to allow for position updates.

Also adds position changes to `marker_test.dart/MarkerController/update` and `markers_test.dart/MarkersController/changeMarkers`. The `MarkersController` case is fixed by this patch.

### Issues

* Grafted from: https://github.com/flutter/plugins/pull/6753
* Fixes: https://github.com/flutter/flutter/issues/83467
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 0a712b4..077d012 100644
--- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md
+++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md
@@ -1,6 +1,7 @@
-## NEXT
+## 0.4.0+8
 
 * Updates minimum Flutter version to 3.3.
+* Allows marker position updates. Issue [#83467](https://github.com/flutter/flutter/issues/83467).
 
 ## 0.4.0+7
 
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 6591b0c..2e2d77b 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 @@
     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 e4c4dd7..6a26406 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
@@ -47,23 +47,86 @@
     });
 
     testWidgets('changeMarkers', (WidgetTester tester) async {
+      gmaps.Marker? marker;
+      gmaps.LatLng? position;
+
       final Set<Marker> markers = <Marker>{
         const Marker(markerId: MarkerId('1')),
       };
       controller.addMarkers(markers);
 
-      expect(
-          controller.markers[const MarkerId('1')]?.marker?.draggable, isFalse);
+      marker = controller.markers[const MarkerId('1')]?.marker;
+      expect(marker, isNotNull);
+      expect(marker!.draggable, isFalse);
 
-      // Update the marker with radius 10
+      // By default, markers fall in LatLng(0, 0)
+      position = marker.position;
+      expect(position, isNotNull);
+      expect(position!.lat, equals(0));
+      expect(position.lng, equals(0));
+
+      // Update the marker with draggable and position
       final Set<Marker> updatedMarkers = <Marker>{
-        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);
+
+      marker = controller.markers[const MarkerId('1')]?.marker;
+      expect(marker, isNotNull);
+      expect(marker!.draggable, isTrue);
+
+      position = marker.position;
+      expect(position, isNotNull);
+      expect(position!.lat, equals(42));
+      expect(position.lng, equals(54));
+    });
+
+    testWidgets(
+        'changeMarkers resets marker position if not passed when updating!',
+        (WidgetTester tester) async {
+      gmaps.Marker? marker;
+      gmaps.LatLng? position;
+
+      final Set<Marker> markers = <Marker>{
+        const Marker(
+          markerId: MarkerId('1'),
+          position: LatLng(42, 54),
+        ),
+      };
+      controller.addMarkers(markers);
+
+      marker = controller.markers[const MarkerId('1')]?.marker;
+      expect(marker, isNotNull);
+      expect(marker!.draggable, isFalse);
+
+      position = marker.position;
+      expect(position, isNotNull);
+      expect(position!.lat, equals(42));
+      expect(position.lng, equals(54));
+
+      // Update the marker without position
+      final Set<Marker> updatedMarkers = <Marker>{
+        const Marker(
+          markerId: MarkerId('1'),
+          draggable: true,
+        ),
+      };
+      controller.changeMarkers(updatedMarkers);
+      expect(controller.markers.length, 1);
+
+      marker = controller.markers[const MarkerId('1')]?.marker;
+      expect(marker, isNotNull);
+      expect(marker!.draggable, isTrue);
+
+      position = marker.position;
+      expect(position, isNotNull);
+      expect(position!.lat, equals(0));
+      expect(position.lng, equals(0));
     });
 
     testWidgets('removeMarkers', (WidgetTester tester) async {
diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/regen_mocks.sh b/packages/google_maps_flutter/google_maps_flutter_web/example/regen_mocks.sh
index 78bcdc0..b3dc17c 100755
--- a/packages/google_maps_flutter/google_maps_flutter_web/example/regen_mocks.sh
+++ b/packages/google_maps_flutter/google_maps_flutter_web/example/regen_mocks.sh
@@ -7,4 +7,4 @@
 
 echo "(Re)generating mocks."
 
-flutter pub run build_runner build --delete-conflicting-outputs
+dart run build_runner build --delete-conflicting-outputs
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 25cba84..dcce8d3 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
@@ -290,17 +290,15 @@
 
 // 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 83f4971..67df16f 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 @@
 description: Web platform implementation of google_maps_flutter
 repository: https://github.com/flutter/packages/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+7
+version: 0.4.0+8
 
 environment:
   sdk: ">=2.18.0 <4.0.0"