createRoute method

Future<Map<String, String>> createRoute(
  1. String currentLatLng,
  2. dynamic destinationLatLng,
  3. String color,
  4. int width,
  5. String apiKey,
)

Implementation

Future<Map<String, String>> createRoute(String currentLatLng, destinationLatLng, String color, int width, String apiKey) async {


  final url = Uri.parse('https://api1.tplmaps.com:8888/route?points=$currentLatLng;$destinationLatLng&profile=car&pointsencoded=false&reroute=false&apikey=$apiKey');

  print(url);

  try {
    final response = await http.get(
      url,
      headers: {
        'Content-Type': 'application/json',
      },

    );

    if (response.statusCode == 200) {

      Map<String, String> etc =   await parseLatLng(response.body , color , width);

      return etc;

    } else {
      // print("${response.body}");
      return {
        'distance': "",
        'time': "",
      };
      throw Exception('Failed to load data');
    }
  } catch (error) {
    return {
      'distance': "",
      'time': "",
    };
    print(error);
  }
}