summaryrefslogtreecommitdiffstats
path: root/lib/map/Show-route.dart
diff options
context:
space:
mode:
authorHritik Chouhan <hritikc3961@gmail.com>2022-09-01 21:47:45 +0200
committerHritik Chouhan <hritikc3961@gmail.com>2022-09-21 12:25:15 +0200
commit0e820517cbcc6d799cf7f23c7041f3f15b732dc0 (patch)
tree93b40a2310e867a2bca5a553dbc0b567f65fb62a /lib/map/Show-route.dart
parent03bb9f818d8caad2213e93e25f085b8672e5ceed (diff)
Upload Flutter-Navigation app for IVI
Flutter Navigation app which Shows current location, Route for destination, search for destination in search bar, turn by turn navigation,duration and distance for destination. Used Mapbox api and Flutter_map plugin and integrated with KUKSA.VAL for current location. Update UI ,Removed unused code and remove hard coded access token. Bug-AGL: SPEC-4548 Signed-off-by: Hritik Chouhan <hritikc3961@gmail.com> Change-Id: I7314285f7b9cdc6940175758761fcc8615c5ab0e
Diffstat (limited to 'lib/map/Show-route.dart')
-rw-r--r--lib/map/Show-route.dart152
1 files changed, 152 insertions, 0 deletions
diff --git a/lib/map/Show-route.dart b/lib/map/Show-route.dart
new file mode 100644
index 0000000..6bb9987
--- /dev/null
+++ b/lib/map/Show-route.dart
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: Apache-2.0
+
+
+import 'package:flutter/material.dart';
+import 'package:flutter_map/flutter_map.dart';
+import 'package:flutter_navigation/config.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:latlong2/latlong.dart';
+import 'package:flutter_navigation/kuksa/class-provider.dart';
+import 'package:flutter_navigation/kuksa/class.dart';
+import 'package:flutter_navigation/map/bottom-card.dart';
+import 'package:flutter_navigation/map/turnNavigation.dart';
+
+class NavigationHome extends ConsumerWidget {
+ final List<LatLng> polyLine;
+ String CurrAddress;
+ String Duration;
+ num Distance;
+
+ NavigationHome({
+ Key? key,
+ required this.polyLine,
+ required this.CurrAddress,
+ required this.Duration,
+ required this.Distance,
+
+ }) : super(key: key);
+
+
+
+ double tempangle = 0;
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+
+ final config = ref.read(ConfigStateprovider);
+
+
+
+ MapController mapController = MapController();
+ VehicleSignal vehicleSignal = ref.watch(vehicleSignalProvider);
+ LatLng currPos = LatLng(vehicleSignal.currentLatitude, vehicleSignal.currentLongitude);
+ LatLng destiPos = LatLng(vehicleSignal.destinationLatitude, vehicleSignal.destinationLongitude);
+
+ return Scaffold(
+
+
+ body: Stack(
+ children: [
+ FlutterMap(
+ mapController: mapController,
+ options: MapOptions(
+
+ center: currPos,
+ minZoom: 1,
+ zoom: 8,
+
+ maxZoom: 22.0,
+ keepAlive: true,
+ ),
+ layers: [
+
+ TileLayerOptions(
+ urlTemplate: "https://api.mapbox.com/styles/v1/hritik3961/cl7j225qm001w14o4xeiqtv36/tiles/256/{z}/{x}/{y}@2x?access_token=${config.mapboxAccessToken}",
+ additionalOptions: {
+ "access_token": config.mapboxAccessToken,
+ },
+ ),
+ if (polyLine.isNotEmpty)
+ PolylineLayerOptions(
+ polylineCulling: false,
+ polylines: [
+
+ Polyline(
+ color : Colors.blue,
+ strokeWidth: 6,
+
+ points: polyLine,
+ ),
+
+ ],
+ ),
+ MarkerLayerOptions(
+ rotate: true,
+ markers: [
+ Marker(
+ point: currPos,
+ width: 70,
+ height: 70,
+ builder: (context) =>
+ const Icon(
+
+ Icons.location_pin,
+ size: 50,
+ color: Colors.red,
+ )
+
+ ),
+ ],
+ ),
+ MarkerLayerOptions(
+ rotate: true,
+ markers: [
+ Marker(
+ point: destiPos,
+ width: 70,
+ height: 70,
+ builder: (context) =>
+ const Icon(
+
+ Icons.location_pin,
+ size: 50,
+ color: Colors.green,
+ )
+
+ ),
+ ],
+ ),
+
+ ],
+ ),
+ Container(
+ alignment: Alignment.topLeft,
+ child :IconButton(
+ icon: Icon(Icons.arrow_back, color: Colors.white,),
+ onPressed: (){
+ Navigator.pop(context);
+ },
+ )
+ ),
+ bottomDetailCard(context,ref,Distance.toString(),Duration.toString(),CurrAddress),
+ ],
+ ),
+
+ floatingActionButton: FloatingActionButton.extended(
+ backgroundColor: Colors.black,
+ onPressed: () async{
+
+
+
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (_) =>
+ TurnNavigation()));
+
+ },
+ label: const Text('lets go'),
+ icon: const Icon(Icons.drive_eta_rounded),
+ ),
+ );
+ }
+} \ No newline at end of file