12/1/1
This commit is contained in:
@@ -2,9 +2,7 @@ import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/constant/style.dart';
|
||||
import 'package:SEFER/controller/functions/location_controller.dart';
|
||||
import 'package:SEFER/views/widgets/elevated_btn.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
@@ -18,21 +16,55 @@ class RideAvailableController extends GetxController {
|
||||
Map rideAvailableMap = {};
|
||||
late LatLng southwest;
|
||||
late LatLng northeast;
|
||||
LatLngBounds calculateBounds(
|
||||
double centerLat, double centerLng, double radius) {
|
||||
// double radius = 4000; // 10 km in meters
|
||||
// LatLngBounds calculateBounds(
|
||||
// double centerLat, double centerLng, double radius) {
|
||||
// // double radius = 4000; // 10 km in meters
|
||||
|
||||
southwest = LatLng(
|
||||
centerLat - (radius / 111000),
|
||||
centerLng - (radius / (111000 * cos(centerLat))),
|
||||
// southwest = LatLng(
|
||||
// centerLat - (radius / 111000),
|
||||
// centerLng - (radius / (111000 * cos(centerLat))),
|
||||
// );
|
||||
|
||||
// northeast = LatLng(
|
||||
// centerLat + (radius / 111000),
|
||||
// centerLng + (radius / (111000 * cos(centerLat))),
|
||||
// );
|
||||
|
||||
// return LatLngBounds(southwest: southwest, northeast: northeast);
|
||||
// }
|
||||
|
||||
LatLngBounds calculateBounds(double lat, double lng, double radiusInMeters) {
|
||||
const double earthRadius = 6378137.0; // Earth's radius in meters
|
||||
|
||||
double latDelta = (radiusInMeters / earthRadius) * (180 / pi);
|
||||
double lngDelta =
|
||||
(radiusInMeters / (earthRadius * cos(pi * lat / 180))) * (180 / pi);
|
||||
|
||||
double minLat = lat - latDelta;
|
||||
double maxLat = lat + latDelta;
|
||||
|
||||
double minLng = lng - lngDelta;
|
||||
double maxLng = lng + lngDelta;
|
||||
|
||||
// Ensure the latitude is between -90 and 90
|
||||
minLat = max(-90.0, minLat);
|
||||
maxLat = min(90.0, maxLat);
|
||||
|
||||
// Ensure the longitude is between -180 and 180
|
||||
minLng = (minLng + 180) % 360 - 180;
|
||||
maxLng = (maxLng + 180) % 360 - 180;
|
||||
|
||||
// Ensure the bounds are in the correct order
|
||||
if (minLng > maxLng) {
|
||||
double temp = minLng;
|
||||
minLng = maxLng;
|
||||
maxLng = temp;
|
||||
}
|
||||
|
||||
return LatLngBounds(
|
||||
southwest: LatLng(minLat, minLng),
|
||||
northeast: LatLng(maxLat, maxLng),
|
||||
);
|
||||
|
||||
northeast = LatLng(
|
||||
centerLat + (radius / 111000),
|
||||
centerLng + (radius / (111000 * cos(centerLat))),
|
||||
);
|
||||
|
||||
return LatLngBounds(southwest: southwest, northeast: northeast);
|
||||
}
|
||||
|
||||
getRideAvailable() async {
|
||||
|
||||
Reference in New Issue
Block a user