Skip to content

Instantly share code, notes, and snippets.

@Shubham-Narkhede
Created November 10, 2019 11:29
Show Gist options
  • Save Shubham-Narkhede/e898f0953dca9e04f7a3cda908aa12e9 to your computer and use it in GitHub Desktop.
Save Shubham-Narkhede/e898f0953dca9e04f7a3cda908aa12e9 to your computer and use it in GitHub Desktop.
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