百度地图api通过经纬度获取地理位置
This commit is contained in:
parent
fbf16fab0e
commit
b92c77d64a
|
|
@ -1,14 +1,17 @@
|
|||
package com.ghy.web.controller.tool;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.config.BaiduConfig;
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.common.utils.http.HttpUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
|
|
@ -21,8 +24,9 @@ public class BaiduController extends BaseController {
|
|||
|
||||
@PostMapping("/getLocation")
|
||||
@ResponseBody
|
||||
public AjaxResult getLocationByLot(String location){
|
||||
public AjaxResult getLocationByLot(@RequestBody JSONObject jsonObject){
|
||||
try {
|
||||
String location = jsonObject.getString("location");
|
||||
String url = baiduConfig.getUrl().replace("#AK#", baiduConfig.getAk()) + location;
|
||||
String result = HttpUtils.sendGet(url);
|
||||
return AjaxResult.success(result);
|
||||
|
|
|
|||
Loading…
Reference in New Issue