undoLocation method

void undoLocation()

Function to undo select location in edit mode

Implementation

void undoLocation() {
  if (_tempLocation.length > 0) {
    _markers.removeWhere((mark) => mark.position == _tempLocation.last);

    if (pointDistance) {
      ///Remove previous distance first point to last point
      _markers.removeWhere((mark) => mark.position == _endLoc);
    }

    _tempLocation.removeLast();
    if (_tempLocation.length == 0) {
      _tempPolygons.clear();
    }

    if (_tempLocation.length > 1 && pointDistance) {
      ///Create distance marker for first point to last point
      createEndLoc(_tempLocation[0], _tempLocation.last);
    }
  }

  if (_distanceLocation.length > 0) {
    _markers.removeWhere((mark) => mark.position == _distanceLocation.last);
    _distanceLocation.removeLast();
  }

  notifyListeners();
}