2026-04-03-maplibra primary succsess
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:Intaleq/controller/home/trip_monitor_controller.dart';
|
||||
import 'package:Intaleq/views/widgets/my_scafold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
import '../../../../constant/colors.dart';
|
||||
@@ -24,31 +23,15 @@ class TripMonitor extends StatelessWidget {
|
||||
return MyScafolld(
|
||||
title: 'Trip Monitor'.tr,
|
||||
body: [
|
||||
GoogleMap(
|
||||
MapLibreMap(
|
||||
onMapCreated: tripMonitorController.onMapCreated,
|
||||
onStyleLoadedCallback: tripMonitorController.onStyleLoaded,
|
||||
initialCameraPosition: CameraPosition(
|
||||
// bearing: 45,
|
||||
target: tripMonitorController.parentLocation,
|
||||
zoom: 16,
|
||||
tilt: 40,
|
||||
),
|
||||
// onCameraMove: (position) {},
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: MarkerId('start'.tr),
|
||||
position: tripMonitorController.parentLocation,
|
||||
draggable: true,
|
||||
icon: tripMonitorController.tripData['message'][0]['model']
|
||||
.contains('دراجة')
|
||||
? tripMonitorController.motoIcon
|
||||
: tripMonitorController.tripData['message'][0]['model']
|
||||
['gender'] ==
|
||||
'Male'
|
||||
? tripMonitorController.carIcon
|
||||
: tripMonitorController.ladyIcon,
|
||||
rotation: tripMonitorController.rotation,
|
||||
),
|
||||
},
|
||||
styleString: "assets/style.json",
|
||||
),
|
||||
speedCircle()
|
||||
],
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:Intaleq/views/widgets/my_scafold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
import '../../../../constant/colors.dart';
|
||||
@@ -30,31 +30,15 @@ class TripMonitor extends StatelessWidget {
|
||||
return MyScafolld(
|
||||
title: 'Trip Monitor'.tr,
|
||||
body: [
|
||||
GoogleMap(
|
||||
MapLibreMap(
|
||||
onMapCreated: tripMonitorController.onMapCreated,
|
||||
onStyleLoadedCallback: tripMonitorController.onStyleLoaded,
|
||||
initialCameraPosition: CameraPosition(
|
||||
// bearing: 45,
|
||||
target: tripMonitorController.parentLocation,
|
||||
zoom: 16,
|
||||
tilt: 40,
|
||||
),
|
||||
// onCameraMove: (position) {},
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: MarkerId('start'.tr),
|
||||
position: tripMonitorController.parentLocation,
|
||||
draggable: true,
|
||||
icon: tripMonitorController.tripData['message'][0]['model']
|
||||
.contains('دراجة')
|
||||
? tripMonitorController.motoIcon
|
||||
: tripMonitorController.tripData['message'][0]['model']
|
||||
['gender'] ==
|
||||
'Male'
|
||||
? tripMonitorController.carIcon
|
||||
: tripMonitorController.ladyIcon,
|
||||
rotation: tripMonitorController.rotation,
|
||||
),
|
||||
},
|
||||
styleString: "assets/style.json",
|
||||
),
|
||||
speedCircle()
|
||||
],
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import 'package:Intaleq/constant/box_name.dart';
|
||||
import 'package:Intaleq/constant/table_names.dart';
|
||||
import 'package:Intaleq/views/widgets/elevated_btn.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import 'package:Intaleq/controller/home/points_for_rider_controller.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/style.dart';
|
||||
// import '../../../controller/functions/location_controller.dart'; // Un-comment if needed
|
||||
// import '../../../controller/home/device_tier.dart'; // Removed to rely on Controller logic
|
||||
import '../../../controller/home/map_passenger_controller.dart';
|
||||
import '../../widgets/mycircular.dart';
|
||||
import '../../widgets/mydialoug.dart';
|
||||
@@ -28,29 +25,46 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: GoogleMap(
|
||||
child: MapLibreMap(
|
||||
onMapCreated: controller.onMapCreated,
|
||||
|
||||
// ✅ Camera Bounds
|
||||
cameraTargetBounds: CameraTargetBounds(controller.boundsdata),
|
||||
onStyleLoadedCallback: () => controller.onStyleLoaded(),
|
||||
styleString: "assets/style.json",
|
||||
|
||||
// ✅ Performance: Smoother zoom limits for low-end devices
|
||||
minMaxZoomPreference: controller.lowPerf
|
||||
? const MinMaxZoomPreference(6, 17)
|
||||
: const MinMaxZoomPreference(6, 18),
|
||||
|
||||
// ✅ Destination Selection on Long Press
|
||||
onLongPress: (LatLng argument) {
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: controller.passengerLocation,
|
||||
zoom: controller.lowPerf ? 14.5 : 15,
|
||||
),
|
||||
|
||||
// ✅ Map Settings
|
||||
myLocationEnabled: true,
|
||||
trackCameraPosition: true,
|
||||
|
||||
// ✅ Camera Movement Logic
|
||||
onCameraIdle: () {
|
||||
if (controller.mapController != null) {
|
||||
final position = controller.mapController!.cameraPosition;
|
||||
if (position != null) {
|
||||
print('✅ onCameraIdle targeted: ${position.target}');
|
||||
// 1. Always update current view target (for pickers)
|
||||
controller
|
||||
.updateCurrentLocationFromCamera(position.target);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onMapLongClick: (point, latlng) {
|
||||
MyDialog().getDialog('Are you want to go to this site'.tr, '',
|
||||
() async {
|
||||
controller.clearPolyline();
|
||||
// Ensure we have car data available before routing
|
||||
// if (controller.dataCarsLocationByPassenger != null) {
|
||||
// i use this check if needed
|
||||
if (controller.carsLocationByPassenger.isNotEmpty) {
|
||||
await controller.getDirectionMap(
|
||||
'${controller.passengerLocation.latitude},${controller.passengerLocation.longitude}',
|
||||
'${argument.latitude},${argument.longitude}',
|
||||
'${latlng.latitude},${latlng.longitude}',
|
||||
);
|
||||
Get.back(); // Close Dialog
|
||||
await controller.bottomSheet();
|
||||
@@ -76,80 +90,9 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
||||
});
|
||||
},
|
||||
|
||||
// ✅ Hide UI elements on tap
|
||||
onTap: (argument) {
|
||||
onMapClick: (point, latlng) {
|
||||
controller.hidePlaces();
|
||||
},
|
||||
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: controller.passengerLocation,
|
||||
zoom: controller.lowPerf ? 14.5 : 15,
|
||||
),
|
||||
|
||||
// ✅ Markers
|
||||
markers: controller.markers.toSet(),
|
||||
|
||||
// ✅ Polygons (e.g., University/Country borders)
|
||||
polygons: controller.polygons,
|
||||
|
||||
// ✅ Polylines: Switch to lighter version if lowPerf is detected
|
||||
polylines: controller.lowPerf
|
||||
? controller.polyLinesLight.toSet()
|
||||
: controller.polyLines.toSet(),
|
||||
|
||||
// ✅ Map Type: Switch to Normal map on low-end devices to save RAM
|
||||
mapType: controller.lowPerf
|
||||
? MapType.normal
|
||||
: (controller.mapType
|
||||
? MapType.satellite
|
||||
: MapType
|
||||
.normal), // Changed terrain default to normal for better performance
|
||||
|
||||
// ✅ UI Settings for Performance
|
||||
myLocationButtonEnabled: false,
|
||||
mapToolbarEnabled: false,
|
||||
tiltGesturesEnabled:
|
||||
false, // Disable tilt to save GPU resources
|
||||
|
||||
// Lite Mode (Static image) only on very low-end Androids if needed,
|
||||
// but usually handled by lowPerf logic in mapType/Traffic
|
||||
liteModeEnabled: Platform.isAndroid && controller.lowPerf,
|
||||
|
||||
trafficEnabled: controller.mapTrafficON && !controller.lowPerf,
|
||||
buildingsEnabled: !controller.lowPerf,
|
||||
rotateGesturesEnabled:
|
||||
!controller.lowPerf, // Disable rotation on low-end
|
||||
|
||||
// ✅ Camera Movement Logic
|
||||
onCameraMove: (CameraPosition position) {
|
||||
// 1. Always update current view target (for pickers)
|
||||
controller.newMyLocation = position.target;
|
||||
|
||||
// 2. Handle Drag-to-Select for specific states
|
||||
if (controller.startLocationFromMap == true) {
|
||||
controller.newStartPointLocation = position.target;
|
||||
} else if (controller.passengerStartLocationFromMap == true) {
|
||||
controller.newStartPointLocation = position.target;
|
||||
}
|
||||
|
||||
// 3. Handle Waypoints Dragging
|
||||
int waypointsLength =
|
||||
Get.find<WayPointController>().wayPoints.length;
|
||||
if (waypointsLength > 0 &&
|
||||
controller.wayPointIndex >= 0 &&
|
||||
controller.wayPointIndex <
|
||||
controller.placesCoordinate.length) {
|
||||
controller.placesCoordinate[controller.wayPointIndex] =
|
||||
'${position.target.latitude},${position.target.longitude}';
|
||||
}
|
||||
|
||||
// 4. Throttle heavy calculations (Reverse Geocoding / API calls)
|
||||
if (controller.lowPerf) {
|
||||
controller.onCameraMoveThrottled(position);
|
||||
}
|
||||
},
|
||||
|
||||
myLocationEnabled: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import 'dart:ui'; // مهم لإضافة تأثير الضبابية
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:Intaleq/controller/home/map_passenger_controller.dart';
|
||||
import 'package:Intaleq/main.dart';
|
||||
import 'package:Intaleq/views/home/map_widget.dart/form_search_places_destenation.dart';
|
||||
import 'package:Intaleq/views/widgets/elevated_btn.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/table_names.dart';
|
||||
import '../../../controller/functions/toast.dart';
|
||||
@@ -760,6 +760,8 @@ class _MapPickerOverlay extends StatelessWidget {
|
||||
controller.newMyLocation.latitude,
|
||||
controller.newMyLocation.longitude,
|
||||
);
|
||||
print('🌐 MAP PICKER CENTER: ${currentCameraPosition.latitude}, ${currentCameraPosition.longitude}');
|
||||
print('✅ _onConfirmTap confirmed coordinates: ${currentCameraPosition.latitude}, ${currentCameraPosition.longitude}');
|
||||
|
||||
// ── CASE 0: Waypoint picker mode ──────────────────────────────────────
|
||||
if (controller.isPickingWaypoint && controller.pickingWaypointIndex >= 0) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:Intaleq/constant/style.dart';
|
||||
import 'package:Intaleq/views/widgets/my_scafold.dart';
|
||||
import 'package:Intaleq/views/widgets/mycircular.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../controller/functions/launch.dart';
|
||||
@@ -72,6 +72,7 @@ class OrderHistory extends StatelessWidget {
|
||||
double.parse(ride['end_location'].toString().split(',')[0]),
|
||||
double.parse(ride['end_location'].toString().split(',')[1]),
|
||||
);
|
||||
|
||||
final LatLngBounds bounds = LatLngBounds(
|
||||
northeast: LatLng(
|
||||
startLocation.latitude > endLocation.latitude
|
||||
@@ -124,32 +125,34 @@ class OrderHistory extends StatelessWidget {
|
||||
height: 150, // ارتفاع ثابت للخريطة
|
||||
child: AbsorbPointer(
|
||||
// لمنع التفاعل المباشر مع الخريطة داخل القائمة
|
||||
child: GoogleMap(
|
||||
child: MapLibreMap(
|
||||
styleString: "assets/style.json",
|
||||
initialCameraPosition:
|
||||
CameraPosition(target: startLocation, zoom: 12),
|
||||
// --- نفس منطق الخريطة والخطوط ---
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
onStyleLoadedCallback: () async {
|
||||
// This is a bit tricky in a list, but we can do it:
|
||||
// Since we don't have the controller here easily without state,
|
||||
// we'll rely on the simple map view or use a stateful widget for each card.
|
||||
// For now, let's keep it simple.
|
||||
},
|
||||
onMapCreated: (MapLibreMapController controller) async {
|
||||
await controller.addSymbol(SymbolOptions(
|
||||
geometry: startLocation,
|
||||
iconImage: 'start_icon',
|
||||
));
|
||||
await controller.addSymbol(SymbolOptions(
|
||||
geometry: endLocation,
|
||||
iconImage: 'end_icon',
|
||||
));
|
||||
await controller.addLine(LineOptions(
|
||||
geometry: [startLocation, endLocation],
|
||||
lineColor: '#${AppColor.primaryColor.value.toRadixString(16).substring(2)}',
|
||||
lineWidth: 4,
|
||||
));
|
||||
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLngBounds(bounds, 60));
|
||||
CameraUpdate.newLatLngBounds(bounds, left: 20, top: 20, right: 20, bottom: 20));
|
||||
},
|
||||
polylines: {
|
||||
Polyline(
|
||||
polylineId: const PolylineId('route'),
|
||||
points: [startLocation, endLocation],
|
||||
color: AppColor.primaryColor,
|
||||
width: 4,
|
||||
),
|
||||
},
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: const MarkerId('start'),
|
||||
position: startLocation),
|
||||
Marker(
|
||||
markerId: const MarkerId('end'),
|
||||
position: endLocation),
|
||||
},
|
||||
mapToolbarEnabled: false,
|
||||
zoomControlsEnabled: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user