地名搜索
简介
地名搜索服务API是一类简单的HTTP/HTTPS接口,包括普通搜索、视野内搜索、周边搜索、拉框搜索、普通建议词搜索等。
使用搜索服务前您需要申请Key
一、搜索请求说明
1.1参数说明
参数 参数说明 参数类型 是否必备 备注
keyWord 搜索的关键字 String 不支持’与&符号。
mapBound 查询的地图范围("-x,-y,x,y") String -180,-90至180,90。
level 目前查询的级别 String 1-20。
specifyAdminCode 指定行政区的国标码 String 9位国标码,如:北京:156110000,优先级高于视野内。
queryRadius 查询半径(周边搜索时) String 周边搜索必备
pointLonlat 点坐标(周边搜索) String 周边搜索必备
queryType 搜索类型(1:普通搜索,2:视野内搜索,3:周边搜索,4:普通建议词搜索,5:公交规划建议词搜索,6:公交规划起止点搜索(只搜索公交站),7: 纯地名搜索(不搜公交线),10:拉框搜索 String 传递参数为1-10,分别对应不同的搜索类型。暂无8和9。
start 返回结果起始位(用于分页和缓存)默认0 String 0-300,表示返回结果的起始位置。
count 返回的结果数量(用于分页和缓存) String 1-300,标书返回结果的条数。
lonlat 查询城市中心点坐标(经纬度坐标) String 例如:北京坐标点是'lonlat':'116.38094,39.92362'。
bound 查询城市矩形范围 String 例如:北京矩形范围是'bound':'116.18198,39.84396,116.5799,40.00327'。
zoom 查询城市缩放级别(1—18级) String 例如:北京的是'zoom':'12'。
layers 查询城市图层(vec:表示矢量、Cva:表示注记) String 例如:'layers':'vec,cva'。
projection 查询城市投影(c:平面坐标投影、w:墨卡托投影) String 例如:'projection':'c'。
1.2传输格式
传输json格式的字符串。结构如下:{"keyWord":keyWord,"mapBound":mapBound,"level":level,"specifyAdminCode":specifyAdminCode,"queryRadius":queryRadius,"queryType":queryType,"start":start,"count":count,"queryTerminal":queryTerminal }
1.3搜索示例
普通搜索:http://api.tianditu.gov.cn/search?postStr={"keyWord":"超市","level":"11","mapBound":"116.04577,39.70307,116.77361,40.09583","queryType":"1","count":"20","start":"0"}&type=query&tk=您的密钥
视野内搜索:http://api.tianditu.gov.cn/search?postStr={"keyWord":"银行","level":"15","mapBound":"116.37552,39.8935,116.42102,39.91804","queryType":"2","count":"20","start":"0"}&type=query&tk=您的密钥
周边搜索:http://api.tianditu.gov.cn/search?postStr={"keyWord":"超市","level":"15","mapBound":"116.40466,39.90684,116.45016,39.93138","queryType":"3","pointLonlat":"116.42844,39.92314","queryRadius":"1000","count":"20","start":"0"}&type=query&tk=您的密钥
拉框搜索:http://api.tianditu.gov.cn/search?postStr={"keyWord":"银行","level":"15","mapBound":"116.37552,39.8935,116.42102,39.91804","queryType":"10","count":"20","start":"0"}&type=query&tk=您的密钥
普通建议词搜索:http://api.tianditu.gov.cn/search?postStr={'keyWord':'超','level':'15','mapBound':'116.40569,39.91088,116.45119,39.93542','queryType':'4','count':'10','start':'0'}&type=query&tk=您的密钥
纯地名搜索: http://api.tianditu.gov.cn/search?postStr={"keyWord":"1","level":"15","mapBound":"116.40569,39.91088,116.45119,39.93542","queryType":"7","count":"20","start":"0","queryTerminal":"10000"}&type=query&tk=您的密钥
二、响应接口
2.1响应格式
响应的数据格式为json格式。
根据搜索类型不同,返回结果有所不同。参数类型为json及json数组的另外有表说明。
参数 参数说明 参数类型 返回条件 备注
resultType 显示类型,1(普通POI),2(统计),3(行政区),4(普通建议词搜索),5(线路结果) Int 必返回 取值1-5,对应不同的响应类型。
count 搜索总条数 Int 必返回
keyword 搜索关键词 String 必返回 搜索的关键字。
pois 针对点(类型1)集合返回 Pois json数组 resultType=1 普通响应时返回。
statistics 针对统计(类型2)集合返回 Json数组 resultType=2 统计响应返回。
area 针对行政区省(类型3)集合点 Json 数组 resultType=3 行政区定位响应返回。
suggests 建议词(类型4)搜索 json reseultType=4 建议词响应返回。
prompt 提示信息,如“您是否在XXX,搜索XXX”,其中包含提示文字及对应的行政区码 json 需要提示时返回
lineData 线路结果 Json 数组 resultType=5 线路响应返回。
pois中的参数为:
参数 参数说明 参数类型 返回条件 备注
name Poi点名称 String 必返回
phone 电话 String 不一定返回
address 地址 String 不一定返回
lonlat 坐标 String 必返回
distance 距离(周边时有) Int resultType=3
poiType poi点的poi类型(102 公交站,普通poi 该参数可以不返回) Int resultType=5
stationData 车站信息结构体 数据 Json 数组 resultType=3
stationUuid 公交站uuid String resultType=3
Stationdata中的参数为:
参数 参数说明 参数类型 返回条件 备注
lineName 线路名称 String 必返回
uuid 线路的id String 必返回
Linedata中的参数为(需要二次请求):
参数 参数说明 参数类型 返回条件 备注
name 线路名称 String 必返回
uuid 线路的id String 必返回
stationNum 站数 String 必返回
statistics中的参数为:
参数 参数说明 参数类型 返回条件 备注
count 本次统计POI总数量 Int 必返回
citysCount 城市数量 Int 必返回
countryCount 国家数量 Int 必返回
priorityCitys 推荐显示城市 Json数组 必返回
allAdmins 各省包含信息集合 Json数组 必返回
provinceCount 省份数量 Int 必返回
priorityCitys中的参数为:
参数 参数说明 参数类型 返回条件 备注
name 城市名称 String 必返回
count 城市数量 Int 必返回
gbCode 城市国标码 Int 必返回 9位国标码。
allAdmins中的参数为:
参数 参数说明 参数类型 返回条件 备注
name 省名称 String 必返回
count 包含数量 Int 必返回
adminCode 省国标码 String 必返回
childAdmins 包括各市级集合 Json数组 直辖市无下级市则不返回。
childAdmins中的参数为:
参数 参数说明 参数类型 返回条件 备注
name 城市名称 String 必返回
count 包含数量 Int 必返回
adminCode 城市国标码 String 必返回
area中的参数为:
参数 参数说明 参数类型 返回条件 备注
name 名称 String 必返回
bound 定位范围(矩形) String
Points 点集合{121.3333 39.222,121.4444 39.223,121.5555 39.265,......}(省级才有) Json数组 必返回 此信息为市或省的边界坐标。
lonlat {121.111,43.111}(定位点) String 必返回 定位中心点坐标。
level 3(显示级别,判断是否存在) Int 必返回 定位级别。
type 1:正常区域,2:特殊区域 Int 必返回 特殊区域暂不适用。
info 区域信息简介 String type=2
Address 特殊区域的地址信息。 String type=2
suggests中的参数为:
参数 参数说明 参数类型 返回条件 备注
name 名称 String 必返回
address 地区地址 String 必返回 可能为空串。
gbCode 国标码 String 必返回
prompt中的参数为:
参数 参数说明 参数类型 返回条件 备注
type 提示类型: 1:是否在where搜what,2:在where无搜索what的结果,3:多个可跳转的行政区提示,4:城市 Int 必返回
admins name:行政区名称(String), adminCode:行政区码(int) Json数组 必返回
keyword 关键字 String
例:当Type=1时,会给出一个 admin 一个keyword 还有admincode,此时一般的提示为“是否在XXX搜索名称含XXX的结果”
当Type = 2时,会给出一个 admin 一个keyword 还有admincode, 此时一般提示为“在XXX没有搜索到相关的结果”
当Type = 2时,会给出一个 admin 一个keyword 还有admincode, 此时一般提示为“在XXX没有搜索到相关的结果”
“您是否要找:
广东省汕尾市城区
山西省晋市城区
山西省大同市城区
山西省长治市城区
山西省阳泉市城区
只列出名称即可,点击后,直接用这些关键字搜索即可完成行政区跳转。