78 lines
3.2 KiB
Dart
78 lines
3.2 KiB
Dart
import 'package:Intaleq/print.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:Intaleq/env/env.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:intaleq_maps/intaleq_maps.dart';
|
|
import 'package:Intaleq/controller/home/points_for_rider_controller.dart';
|
|
import 'package:Intaleq/services/offline_map_service.dart';
|
|
|
|
import '../../../controller/home/map_passenger_controller.dart';
|
|
import '../../widgets/mycircular.dart';
|
|
import '../../widgets/mydialoug.dart';
|
|
|
|
class GoogleMapPassengerWidget extends StatelessWidget {
|
|
GoogleMapPassengerWidget({super.key});
|
|
|
|
final WayPointController wayPointController = Get.put(WayPointController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetBuilder<MapPassengerController>(
|
|
builder: (controller) => controller.isLoading
|
|
? const MyCircularProgressIndicator()
|
|
: Positioned(
|
|
bottom: Get.height * .2,
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: IntaleqMap(
|
|
apiKey: Env.mapSaasKey,
|
|
styleUrl: Get.isDarkMode
|
|
? 'assets/style_dark.json'
|
|
: 'assets/style.json',
|
|
onMapCreated: controller.onMapCreated,
|
|
onStyleLoaded: controller.onStyleLoaded,
|
|
onCameraMove: controller.onCameraMoveThrottled,
|
|
onCameraIdle: () {
|
|
if (controller.mapController != null) {
|
|
final position = controller.mapController!.cameraPosition;
|
|
if (position != null) {
|
|
Log.print('✅ onCameraIdle targeted: ${position.target}');
|
|
controller
|
|
.updateCurrentLocationFromCamera(position.target);
|
|
OfflineMapService.instance
|
|
.downloadRegion(position.target, radiusKm: 1.0);
|
|
} else {
|
|
Log.print('⚠️ onCameraIdle: cameraPosition is NULL');
|
|
}
|
|
} else {
|
|
Log.print('⚠️ onCameraIdle: mapController is NULL');
|
|
}
|
|
},
|
|
markers: controller.markers,
|
|
polylines: controller.polyLines,
|
|
polygons: controller.polygons,
|
|
circles: controller.circles,
|
|
initialCameraPosition: CameraPosition(
|
|
target: controller.passengerLocation,
|
|
zoom: controller.lowPerf ? 14.5 : 15,
|
|
),
|
|
myLocationEnabled: true,
|
|
onTap: (latlng) => controller.hidePlaces(),
|
|
onLongPress: (latlng) {
|
|
MyDialog().getDialog('Are you want to go to this site'.tr, '',
|
|
() async {
|
|
controller.clearPolyline();
|
|
controller.getDirectionMap(
|
|
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
|
'${latlng.latitude},${latlng.longitude}',
|
|
);
|
|
controller.showBottomSheet1();
|
|
});
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|