增加百度提示接口
This commit is contained in:
parent
290ef1da9b
commit
100f197bee
@ -121,13 +121,38 @@ public class BaiduMapServiceImpl {
|
||||
* 用户可通过该服务,匹配用户输入关键词的地点推荐列表。
|
||||
* 参考:https://api.map.baidu.com/place/v2/suggestion?query=天安门®ion=北京&city_limit=true&output=json&ak=你的ak
|
||||
*
|
||||
* @param query 上地、天安、中关、shanghai
|
||||
* @param region 北京市、上海市等。支持城市及对应百度编码(Citycode)。(指定的区域的返回结果加权,可能返回其他城市高权重结果。若要对返回结果区域严格限制,请使用city_limit参数)
|
||||
* @param query 上地、天安、中关、shanghai
|
||||
* @param region 北京市、上海市等。支持城市及对应百度编码(Citycode)。(指定的区域的返回结果加权,可能返回其他城市高权重结果。若要对返回结果区域严格限制,请使用city_limit参数)
|
||||
* @param city_limit 可选参数,取值为"true"或"false",true:仅返回region中指定城市检索结果,false:返回region中指定城市检索结果及相邻城市结果
|
||||
* @param coord_type 传入的坐标类型,可选参数,用于标注请求中「location」参数使用的坐标类型:1(WGS84ll即GPS经纬度)2(GCJ02ll即国测局经纬度坐标) 3(BD09ll即百度经纬度坐标) 4(BD09mc即百度米制坐标)
|
||||
* @param ret_coordtype 返回的坐标类型,可选参数,添加后POI返回国测局经纬度坐标,若不传该参数,返回结果默认bd09ll(百度经纬度)
|
||||
* @return
|
||||
*/
|
||||
public JSONObject placeSuggestion(String query, String region) {
|
||||
String apiUrl = "https://api.map.baidu.com/place/v2/suggestion?query=" + query + "®ion=" + region + "&city_limit=true&output=json&ak=" + ak;
|
||||
String respJson = RestTemplateHttpUtil.sendGet(apiUrl, String.class);
|
||||
public JSONObject placeSuggestion(String query, String region, Boolean city_limit, String coord_type, String ret_coordtype) {
|
||||
StringBuilder apiUrl = new StringBuilder("https://api.map.baidu.com/place/v2/suggestion");
|
||||
apiUrl.append("?output=json").append("&ak=").append(ak);
|
||||
|
||||
if (StrUtil.isNotBlank(query)) {
|
||||
apiUrl.append("&query=").append(query);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(region)) {
|
||||
apiUrl.append("®ion=").append(region);
|
||||
}
|
||||
|
||||
if (city_limit != null) {
|
||||
apiUrl.append("&city_limit").append(city_limit);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(coord_type)) {
|
||||
apiUrl.append("&coord_type=").append(coord_type);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(ret_coordtype)) {
|
||||
apiUrl.append("&ret_coordtype=").append(ret_coordtype);
|
||||
}
|
||||
|
||||
String respJson = RestTemplateHttpUtil.sendGet(apiUrl.toString(), String.class);
|
||||
return JSONUtil.parseObj(respJson);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,10 +17,7 @@ import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
|
||||
import com.suisung.mall.shop.store.service.ShopMerchEntryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
@ -118,7 +115,11 @@ public class ShopMerchEntryController extends BaseControllerImpl {
|
||||
*/
|
||||
@ApiOperation(value = "百度地图地点输入提示", notes = "地点输入提示服务(又名Place Suggestion API)是一类Web API接口服务。")
|
||||
@RequestMapping(value = "/baidu/place/v2/suggestion", method = RequestMethod.GET)
|
||||
public JSONObject baiduMapSuggestion(String query, String region) {
|
||||
return baiduMapService.placeSuggestion(query, region);
|
||||
public JSONObject baiduMapSuggestion(@RequestParam(name = "query", required = true) String query,
|
||||
@RequestParam(name = "region", required = true) String region,
|
||||
@RequestParam(name = "city_limit", required = false) Boolean city_limit,
|
||||
@RequestParam(name = "coord_type", required = false) String coord_type,
|
||||
@RequestParam(name = "ret_coordtype", required = false) String ret_coordtype) {
|
||||
return baiduMapService.placeSuggestion(query, region, city_limit, coord_type, ret_coordtype);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user