接口地址:https://api.jisuapi.com/transit/nearby 返回格式:JSON,JSONP 请求方法:GET POST 请求示例:
https://api.jisuapi.com/transit/nearby?city=杭州&address=西溪花园紫菱苑&appkey=yourappkey
请求参数:
参数名称 | 类型 | 必填 | 说明 |
---|---|---|---|
city | string | 是 | 城市 |
address | string | 是 | 地址 |
返回参数:
参数名称 | 类型 | 说明 |
---|---|---|
station | string | 站点名称 |
lat | string | 站点纬度 |
lng | string | 站点经度 |
distance | string | 距离(米) |
lines | string | 线路列表 |
API错误码:
代号 | 说明 |
---|---|
201 | 公交车次为空 |
202 | 城市ID为空 |
203 | 起点为空 |
204 | 终点为空 |
205 | 城市为空 |
206 | 公交站点为空 |
207 | 地址为空 |
210 | 没有信息 |
系统错误码:
代号 | 说明 |
---|---|
101 | APPKEY为空或不存在 |
102 | APPKEY已过期 |
103 | APPKEY无请求此数据权限 |
104 | 请求超过次数限制 |
105 | IP被禁止 |
106 | IP请求超过限制 |
107 | 接口维护中 |
108 | 接口已停用 |
请求API:https://api.jisuapi.com/transit/line?cityid=382&transitno=86&appkey=你的密钥
返回JSON:
{
"status": 0,
"msg": "ok",
"result": [
{
"transitno": "86路",
"startstation": "西溪竞舟苑",
"endstation": "景芳小区",
"starttime": "05:45",
"endtime": "21:45",
"price": "2",
"maxprice": "2.00",
"list": [
{
"sequenceno": 1,
"station": "西溪竞舟苑",
"lat": "30.28806",
"lng": "120.06484"
},
{
"sequenceno": 22,
"station": "和平广场",
"lat": "30.29524",
"lng": "120.18258"
},
{
"sequenceno": 25,
"station": "濮家新村",
"lat": "30.29059",
"lng": "120.20558"
},
{
"sequenceno": 29,
"station": "景芳小区",
"lat": "30.27631",
"lng": "120.21277"
}
]
},
{
"transitno": "86路",
"startstation": "景芳小区",
"endstation": "西溪竞舟苑",
"starttime": "05:45",
"endtime": "21:45",
"price": "2",
"maxprice": "2.00",
"list": [
{
"sequenceno": 1,
"station": "景芳小区",
"lat": "30.27628",
"lng": "120.21274"
},
{
"sequenceno": 2,
"station": "濮家新村",
"lat": "30.28873",
"lng": "120.20592"
},
{
"sequenceno": 25,
"station": "西溪竞舟苑",
"lat": "30.28807",
"lng": "120.06484"
}
]
}
]
}
/**
* 得到周边站址
*/
getStationList() {
var _this = this
// 调用接口
var locationInfo = _this.data.locationInfo
console.log(locationInfo)
wx.request({
url: 'http://api.jisuapi.com/transit/nearby', //周围地址接口
data: {
appkey: config.Config.busappkey,
city: locationInfo.city,
address: locationInfo.address
},
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
var stationList = res.data.result
console.log(stationList)
console.log(stationList.length)
for (var i = 0; i < stationList.length; i++) {
if(stationList[i].lines !=undefined){
var temp = []
for (var j = 0; j < stationList[i].lines.length; j++) {
var line = stationList[i].lines[j]
var newLine = line.substring(0, line.indexOf('('))
if (temp.indexOf(newLine) == -1) {
temp.push(newLine)
}
}
stationList[i].lines = temp
}
}
_this.setData({
stationList: stationList
})
//设置标记点
_this.setMapMarkers()
console.log(_this.data.stationList)
},
fail: function (res) {
console.log(res);
},
complete: function (res) {
app.hideLoading()
// console.log(res);
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
}
})
},
本篇获取周边站址的API是第三方API,第三方API其实在应用中很常见比如:车牌识别、图片搜索、短信接口、语音识别、语音合成、天气数据、地铁查询、实时物流、飞机查询等等。
相关地图API接口: