onTapMap method

void onTapMap(
  1. LatLng _location, {
  2. TrackingMode? mode = TrackingMode.PLANAR,
})

Function to handle onTap Map and get location

Implementation

void onTapMap(LatLng _location,
    {TrackingMode? mode = TrackingMode.PLANAR}) async {
  if (isEditMode == true) {
    ///Find center position between two coordinate
    if (_tempLocation.length > 0) {
      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], _location);
      }

      if (pointDistance) {
        ///Create distance marker for last positions
        await createDistanceMarker(_tempLocation.last, _location);
      }
    }

    ///Adding new locations
    _tempLocation.add(_location);
    if (_uniqueID == "") {
      _uniqueID = Random().nextInt(10000).toString();
    }

    ///Create marker point
    Uint8List? markerIcon = await getUint8List(markerKey);
    setMarkerLocation(_tempLocation.length.toString(), _location, markerIcon);

    ///Set current tracking mode
    ///so we can use this variable in every function
    setTrackingMode(mode);
    if (trackingMode == TrackingMode.PLANAR) {
      setTempToPolygon();
    } else {
      setTempToPolyline();
    }
  }
  notifyListeners();
}