Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
[google_maps_flutter_web] Allow marker position updates
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.
  • Loading branch information
AsturaPhoenix committed Apr 12, 2023
commit 544002d3d3d0b1077c26b7b3e12c2cbaa30eb40c
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,21 @@ 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<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);
final 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_web
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"
Expand Down