updateNewMarkerLocation method

void updateNewMarkerLocation(
  1. String id,
  2. LatLng _newLoc
)

Updating new marker and polygon location when the marker is dragged

Implementation

void updateNewMarkerLocation(String id, LatLng _newLoc) async {
  _tempLocation[int.parse(id) - 1] = _newLoc;

  if (trackingMode == TrackingMode.PLANAR) {
    setTempToPolygon();
  } else {
    setTempToPolyline();
  }

  ///Refresh distance marker
  for (var distance in _distanceLocation) {
    removeMarkerByLatlong(distance);
  }
  _distanceLocation.clear();
  for (int i = 0; i < _tempLocation.length; i++) {
    if (i + 1 < _tempLocation.length) {
      await createDistanceMarker(_tempLocation[i], _tempLocation[i + 1]);
    }
  }

  if (_tempLocation.length > 1 && pointDistance) {
    ///Remove previous distance first point to last point
    await removeMarker(_endLoc);

    ///Create distance marker for first point to last point
    await createEndLoc(_tempLocation[0], _tempLocation.last);
  }
  notifyListeners();
}