Add distance to map lat lang

dev
suresh 1 year ago
parent 33a0dbb24e
commit a189751141

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 KiB

After

Width:  |  Height:  |  Size: 422 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

@ -1,8 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:developer'; import 'dart:developer';
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart'; import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -13,7 +11,6 @@ import 'location_controller.dart';
class OrderTrackingPage extends StatefulWidget { class OrderTrackingPage extends StatefulWidget {
var lat; var lat;
var lng; var lng;
OrderTrackingPage({ OrderTrackingPage({
@ -56,9 +53,7 @@ class OrderTrackingPageState extends State<OrderTrackingPage> {
getDirections(endLocation); getDirections(endLocation);
} }
}); });
getDirections(endLocation); //fetch direction polylines from Google API getDirections(endLocation); //fetch direction polylines from Google API
} }
getDirections(endLocation) async { getDirections(endLocation) async {
@ -101,6 +96,23 @@ class OrderTrackingPageState extends State<OrderTrackingPage> {
// log(result.errorMessage ?? "Something went wrong"); // log(result.errorMessage ?? "Something went wrong");
} }
/* if (result.status == "OK") {
final route = result.routes.first;
final leg = route.legs.first;
final distance = leg.distance?.text ?? '';
final duration = leg.duration?.text ?? '';
print('Distance: $distance');
print('Duration: $duration');
} else {
print('Error: ${result.errorMessage}');
}*/
//polulineCoordinates is the List of longitute and latidtude. //polulineCoordinates is the List of longitute and latidtude.
double totalDistance = 0; double totalDistance = 0;
for(var i = 0; i < polylineCoordinates.length-1; i++){ for(var i = 0; i < polylineCoordinates.length-1; i++){
@ -119,6 +131,10 @@ class OrderTrackingPageState extends State<OrderTrackingPage> {
addPolyLine(polylineCoordinates); addPolyLine(polylineCoordinates);
} }
addPolyLine(List<LatLng> polylineCoordinates) async { addPolyLine(List<LatLng> polylineCoordinates) async {
PolylineId id = const PolylineId("poly"); PolylineId id = const PolylineId("poly");
Polyline polyline = Polyline( Polyline polyline = Polyline(
@ -148,9 +164,6 @@ class OrderTrackingPageState extends State<OrderTrackingPage> {
return 12742 * asin(sqrt(a)); return 12742 * asin(sqrt(a));
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -200,7 +213,6 @@ class OrderTrackingPageState extends State<OrderTrackingPage> {
], ],
) )
); );
} }

Loading…
Cancel
Save