Created
November 10, 2019 11:29
-
-
Save Shubham-Narkhede/e898f0953dca9e04f7a3cda908aa12e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:google_maps_flutter/google_maps_flutter.dart'; | |
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
const apiKey = "AIzaSyBhDflq5iJrXIcKpeq0IzLQPQpOboX91lY"; | |
class GoogleMapsServices{ | |
Future<String> getRouteCoordinates(LatLng l1, LatLng l2)async{ | |
String url = "https://maps.googleapis.com/maps/api/directions/json?origin=${l1.latitude},${l1.longitude}&destination=${l2.latitude},${l2.longitude}&key=$apiKey"; | |
http.Response response = await http.get(url); | |
Map values = jsonDecode(response.body); | |
return values["routes"][0]["overview_polyline"]["points"]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment