新建一个测试类 TestBaiduYingyan
package cn.itcast.baidumap; import cn.hutool.http.HttpRequest; import org.junit.Test; public class TestBaiduYingyan { private String ak = "i0stCezN9kXNkfp5dEmPsMg7eIkFWquh"; /** * 新增实体 */ @Test public void testEntityAdd(){ String url="https://yingyan.baidu.com/api/v3/entity/add"; String body = HttpRequest.post(url) .form("ak", ak) .form("service_id", 233936) .form("entity_name", "route_1_1001") .form("entity_desc", "用户1创建的1001路线") .execute().body(); System.out.println(body); } }
/** * 新增实体(自定义字段) */ @Test public void testEntityAdd(){ String url="https://yingyan.baidu.com/api/v3/entity/add"; String body = HttpRequest.post(url) .form("ak", ak) .form("service_id", 233936) .form("entity_name", "route_1_1002") .form("entity_desc", "用户1创建的1002路线") .form("routeName", "用户1的1002路线") .execute().body(); System.out.println(body); }
/** * 更新实体(自定义字段) */ @Test public void testEntityUpdate(){ String url="https://yingyan.baidu.com/api/v3/entity/update"; String body = HttpRequest.post(url) .form("ak", ak) .form("service_id", 233936) .form("entity_name", "route_1_1001") .form("entity_desc", "用户1创建的1001路线更新") .form("routeName", "用户1的1001路线") .execute().body(); System.out.println(body); }
删除Entity
/** * 删除实体(自定义字段) */ @Test public void testEntityDelete(){ String url="https://yingyan.baidu.com/api/v3/entity/delete"; String body = HttpRequest.post(url) .form("ak", ak) .form("service_id", 233936) .form("entity_name", "route_1_1001") .execute().body(); System.out.println(body); }
查询
/** * 查询体(自定义字段) */ @Test public void testEntityList(){ String url="https://yingyan.baidu.com/api/v3/entity/list"; String body = HttpRequest.get(url) .form("ak", ak) .form("service_id", 233936) .form("filter","entity_names:route_1_1002") .form("coord_type_output","gcj02")//返回坐标体系 .execute().body(); System.out.println(body);