package com.ruoyi.web.util;
|
|
import okhttp3.OkHttpClient;
|
import okhttp3.Request;
|
import okhttp3.Response;
|
|
import java.io.IOException;
|
|
public class AmapApiClient {
|
private static final String KEY = "e700a58329a38b2d8980790d9b1b5b06";
|
private static final OkHttpClient client = new OkHttpClient();
|
|
public static String getDrivingRoute(double startLat, double startLon, double endLat, double endLon) throws IOException {
|
String url = "https://restapi.amap.com/v3/direction/walking?" +
|
"origin=" + startLon + "," + startLat +
|
"&destination=" + endLon + "," + endLat +
|
"&key=" + KEY;
|
|
Request request = new Request.Builder()
|
.url(url)
|
.build();
|
|
try (Response response = client.newCall(request).execute()) {
|
return response.body().string();
|
}
|
}
|
}
|