liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/GaodeMapService.java
@@ -2,6 +2,8 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xiaopeng.map.config.MapApiConfigHolder;
import com.xiaopeng.map.config.MapApiProperties;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -13,17 +15,17 @@
import java.nio.charset.StandardCharsets;
public class GaodeMapService {
    // 高德地图API基础URL
    private static final String WALKING_API_URL = "https://restapi.amap.com/v3/direction/walking";
    // 你的高德地图API Key
    private String apiKey;
    public GaodeMapService(String apiKey) {
        this.apiKey = apiKey;
    private final String walkingApiUrl;
    private final String apiKey;
    public GaodeMapService() {
        MapApiProperties properties = MapApiConfigHolder.getProperties();
        this.walkingApiUrl = properties.getUrls().getWalking();
        this.apiKey = properties.getApiKey();
    }
    /**
     * 获取步行路径规划
     * @param origin 起点坐标,格式:经度,纬度
@@ -56,7 +58,7 @@
     */
    private String buildWalkingUrl(String origin, String destination) {
        return String.format("%s?origin=%s&destination=%s&key=%s",
                WALKING_API_URL,
                walkingApiUrl,
                origin,
                destination,
                apiKey);
@@ -113,4 +115,4 @@
        
        return result;
    }
}
}