Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
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
39 changes: 32 additions & 7 deletions packages/google_maps_flutter/lib/src/marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,40 @@ class Marker {
}

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
final Marker typedOther = other;
return markerId == typedOther.markerId;
}
bool operator ==(Object other) =>
identical(this, other) ||
other is Marker &&
runtimeType == other.runtimeType &&
markerId == other.markerId &&
alpha == other.alpha &&
anchor == other.anchor &&
consumeTapEvents == other.consumeTapEvents &&
draggable == other.draggable &&
flat == other.flat &&
icon == other.icon &&
infoWindow == other.infoWindow &&
position == other.position &&
rotation == other.rotation &&
visible == other.visible &&
zIndex == other.zIndex &&
onTap == other.onTap;

@override
int get hashCode => markerId.hashCode;
int get hashCode => hashValues(
markerId,
alpha,
anchor,
anchor,
consumeTapEvents,
draggable,
flat,
icon,
infoWindow,
position,
rotation,
visible,
zIndex,
onTap);

@override
String toString() {
Expand Down
11 changes: 7 additions & 4 deletions packages/google_maps_flutter/lib/src/marker_updates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class _MarkerUpdates {
final Set<MarkerId> prevMarkerIds = previousMarkers.keys.toSet();
final Set<MarkerId> currentMarkerIds = currentMarkers.keys.toSet();

final Set<Marker> previousMarkersSet =
Set<Marker>.of(previousMarkers.values);
final Set<Marker> currentMarkersSet = Set<Marker>.of(currentMarkers.values);

Marker idToCurrentMarker(MarkerId id) {
return currentMarkers[id];
}
Expand All @@ -36,10 +40,9 @@ class _MarkerUpdates {
.map(idToCurrentMarker)
.toSet();

final Set<Marker> _markersToChange = currentMarkerIds
.intersection(prevMarkerIds)
.map(idToCurrentMarker)
.toSet();
final Set<Marker> _markersToChange = currentMarkersSet
.difference(previousMarkersSet)
..removeAll(_markersToAdd);

markersToAdd = _markersToAdd;
markerIdsToRemove = _markerIdsToRemove;
Expand Down