# MarkerUpdates.from constructor

MarkerUpdates.from(

1. Set <Marker> previous,
2. Set <Marker> current

)

根据之前的marker列表`previous`和当前的marker列表`current`创建`MakerUpdates`.

## Implementation

    MarkerUpdates.from(Set<Marker> previous, Set<Marker> current) {
      if (previous == null) {
        previous = Set<Marker>.identity();
      }

      if (current == null) {
        current = Set<Marker>.identity();
      }

      final Map<String, Marker> previousMarkers = keyByMarkerId(previous);
      final Map<String, Marker> currentMarkers = keyByMarkerId(current);

      final Set<String> prevMarkerIds = previousMarkers.keys.toSet();
      final Set<String> currentMarkerIds = currentMarkers.keys.toSet();

      Marker idToCurrentMarker(String id) {
        return currentMarkers[id];
      }

      final Set<String> _markerIdsToRemove =
          prevMarkerIds.difference(currentMarkerIds);

      final Set<Marker> _markersToAdd = currentMarkerIds
          .difference(prevMarkerIds)
          .map(idToCurrentMarker)
          .toSet();

      bool hasChanged(Marker current) {
        final Marker previous = previousMarkers[current.id];
        return current != previous;
      }

      final Set<Marker> _markersToChange = currentMarkerIds
          .intersection(prevMarkerIds)
          .map(idToCurrentMarker)
          .where(hasChanged)
          .toSet();

      markersToAdd = _markersToAdd;
      markerIdsToRemove = _markerIdsToRemove;
      markersToChange = _markersToChange;
    }