提交 4d82ee00 authored 作者: 000516's avatar 000516

腾讯位置服务-根据经纬度获取地址信息

上级 9c60e882
package com.sfa.system.controller.tencentquery;
import com.alibaba.fastjson2.JSONObject;
import com.sfa.system.utils.TencentLbsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : liqiulin
* @date : 2025-09-05 11
* @describe : 腾讯地图查询
*/
@RestController
@RequestMapping("/tencent/lbs")
public class LbsQueryController {
@Autowired
private TencentLbsUtil tencentLbsUtil;
/**
* 根据经纬度查询地址
* @param location 经纬度
* @return 地址
*/
@GetMapping("/address")
public JSONObject addressByLocation(String location) {
return tencentLbsUtil.addressByLocation(location);
}
}
package com.sfa.system.utils;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author : liqiulin
* @date : 2025-09-05 11
* @describe :
*/
@Component
public class TencentLbsUtil {
@Value("${tencent.lbs.key}")
private String key;
@Value("${tencent.lbs.url}")
private String url;
public JSONObject addressByLocation(String location){
Map<String,Object> params = new HashMap<>();
params.put("location",location);
params.put("key",key);
String bodyStr = HttpUtil.get(url, params);
return JSONObject.parseObject(bodyStr);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论