8-12/
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'dart:math' as math;
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:google_polyline_algorithm/google_polyline_algorithm.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/functions/crud.dart';
|
||||
import 'package:ride/views/home/map_widget.dart/buttom_sheet_map_show.dart';
|
||||
|
||||
@@ -24,7 +21,9 @@ class MapController extends GetxController {
|
||||
late LatLng newMylocation = const LatLng(32.115295, 36.064773);
|
||||
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
final List<LatLng> carsLocationByPassenger = [];
|
||||
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
double height = 200;
|
||||
final location = Location();
|
||||
late LocationData currentLocation;
|
||||
@@ -110,7 +109,21 @@ class MapController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
void addCustomCarIcon() {
|
||||
ImageConfiguration config = const ImageConfiguration(
|
||||
size: Size(50, 50),
|
||||
// scale: 1.0,
|
||||
);
|
||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
|
||||
.then((value) {
|
||||
carIcon = value;
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getLocation() async {
|
||||
isloading = true;
|
||||
update();
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
@@ -134,16 +147,33 @@ class MapController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// Configure location accuracy
|
||||
LocationAccuracy desiredAccuracy = LocationAccuracy.high;
|
||||
|
||||
// Get the current location
|
||||
LocationData _locationData = await location.getLocation();
|
||||
mylocation =
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
// print('accuracy' + _locationData.accuracy.toString());
|
||||
// print(_locationData.latitude);
|
||||
// print(_locationData.time);
|
||||
// print('//////////////////////////////////////');
|
||||
|
||||
// Print location details
|
||||
print('Accuracy: ${_locationData.accuracy}');
|
||||
print('Latitude: ${_locationData.latitude}');
|
||||
print('Longitude: ${_locationData.longitude}');
|
||||
print('Time: ${_locationData.time}');
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future getCarsLocationByPassenger() async {
|
||||
List data =
|
||||
await CRUD().get(link: AppLink.getCarsLocationByPassenger, payload: {});
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
carsLocationByPassenger.add(LatLng(double.parse(data[i]['latitude']),
|
||||
double.parse(data[i]['longitude'])));
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -357,11 +387,13 @@ class MapController extends GetxController {
|
||||
List<LatLng> polylineCoordinate = [];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
// getPolyLine();
|
||||
// getMap();
|
||||
getLocation();
|
||||
await getCarsLocationByPassenger();
|
||||
addCustomPicker();
|
||||
addCustomCarIcon();
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user