Untitled

 avatar
unknown
plain_text
2 years ago
2.2 kB
8
Indexable
void searchByPinTask(LocationType type) {
    _bookingMapController.clearMap();
    resetData();
    mapEvents.value = MapEvents.NONE;
    _searchByPin.value = true;
    locationType.value = type;

    if (type == LocationType.PICKUP) {
      (pickUpLocation != null)
          ? _bookingMapController.moveCameraToLocation(pickUpLocation)
          : moveToCurrentLocation();
    } else if (type == LocationType.WORK) {
      (workLocation != null)
          ? _bookingMapController.moveCameraToLocation(workLocation)
          : moveToCurrentLocation();
    } else if (type == LocationType.HOME) {
      (homeLocation != null)
          ? _bookingMapController.moveCameraToLocation(homeLocation)
          : moveToCurrentLocation();
    } else {
      (destinationLocation != null)
          ? _bookingMapController.moveCameraToLocation(destinationLocation)
          : moveToCurrentLocation();
    }
  }

moveCameraToLocation(LatLng location, {double zoomLevel = 16}) async {
    CameraMovement.moveCameraPosition(
        location: location,
        googleMapsController: _mapController,
        zoomLevel: zoomLevel);
  }

Widget build(BuildContext context) {
    return GetBuilder<BookingMapController>(
      builder: (myController) => Obx(
        () => GoogleMap(
          initialCameraPosition:
              CameraPosition(zoom: 10, target: SessionManager.instance.currentLocation),
          myLocationEnabled: true,
          myLocationButtonEnabled: false,
          onCameraMove: (data) {
            controller.updateLastCameraLocation(
                LatLng(data.target.latitude, data.target.longitude));
            controller.updatePlaceName('${LocaleKeys.text_searching.tr}...');
          },
          onCameraIdle: () {
            controller.updateCameraStatus();
          },
          compassEnabled: false,
          mapType: MapType.normal,
          polylines: myController.polylines,
          zoomGesturesEnabled: true,
          // polygons: PolygonPoints.myPolygon(),
          zoomControlsEnabled: false,
          markers: controller.markers.value,
          onMapCreated: (GoogleMapController _controller) {
            controller.updateMapController(_controller);
          },
        ),
      ),
    );
  }
Editor is loading...