feat:门店经纬度更新
This commit is contained in:
@@ -3,6 +3,7 @@ package com.cool.store.utils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -16,6 +17,7 @@ import java.net.URL;
|
||||
* @Description:
|
||||
* @date 2024-04-23 11:26
|
||||
*/
|
||||
@Slf4j
|
||||
public class GeoMapUtil {
|
||||
|
||||
private static final String AMAP_API_URL = "https://restapi.amap.com/v3/geocode/regeo";
|
||||
@@ -64,14 +66,19 @@ public class GeoMapUtil {
|
||||
if (geoJson==null){
|
||||
return new AddressInfo();
|
||||
}
|
||||
JSONObject addressComponent = geoJson.getJSONObject("addressComponent");
|
||||
// 根据实际响应结构解析省市区街道信息,此处仅为示例
|
||||
String province = (String) addressComponent.get("province");
|
||||
String city = addressComponent.get("city") instanceof String?(String) addressComponent.get("city"):province;
|
||||
String district = addressComponent.get("district") instanceof String?(String) addressComponent.get("district"):city;
|
||||
String township =addressComponent.get("township") instanceof String?(String) addressComponent.get("township"):district;
|
||||
String address = geoJson.getString("formatted_address");
|
||||
return new AddressInfo(province, city, district, township, address);
|
||||
try {
|
||||
JSONObject addressComponent = geoJson.getJSONObject("addressComponent");
|
||||
// 根据实际响应结构解析省市区街道信息,此处仅为示例
|
||||
String province = (String) addressComponent.get("province");
|
||||
String city = addressComponent.get("city") instanceof String?(String) addressComponent.get("city"):province;
|
||||
String district = addressComponent.get("district") instanceof String?(String) addressComponent.get("district"):city;
|
||||
String township =addressComponent.get("township") instanceof String?(String) addressComponent.get("township"):district;
|
||||
String address = geoJson.getString("formatted_address");
|
||||
new AddressInfo(province, city, district, township, address);
|
||||
}catch (Exception exception){
|
||||
log.info("高德数据获取异常{}",exception.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
Reference in New Issue
Block a user