通过谷歌地图Api获取公交路线中途停留的名称/坐标

问题描述 投票:2回答:1

我试图通过googleMaps js API查找在公交路线上停靠的名称/坐标我使用travelMode中的directionsService函数,这是一个示例输出:

{
 "arrival_stop": {},
 "arrival_time": {},
 "departure_stop": {},
 "departure_time": {},
 "headsign": "Green Westbound to Bankhead Station",
 "line": {},
 "num_stops": 1
}

当一条路线从a转到b而停在c时,directionsService会告诉我停靠点数(num_stops)但不是它们的名称或坐标。在原生iOS应用程序中它。 Web API中是否还不支持此功能,还是我错过了某些内容?

还有其他人在使用其他路由服务,支持此功能吗?

google-maps maps here-api map-directions
1个回答
0
投票

原来here API可以提供以下信息:

curl \
-X GET \
-H 'Content-Type: *' \
--get 'https://transit.api.here.com/v3/route.json' \
--data-urlencode 'dep=52.521504,13.41126' \
--data-urlencode 'arr=52.515829,13.45395' \
--data-urlencode 'time=2018-11-19T07:30:00' \
--data-urlencode 'app_id=devportal-demo-20180625' \
--data-urlencode 'app_code=9v2BkviRwi9Ot26kp2IysQ' \
--data-urlencode 'routing=tt'

会像这样返回一个json(摘录)

"Journey": {
"duration": "PT6M",
"Stop": [
{
    "dep": "2018-11-19T07:51:00",
    "Stn": {
    "id": "vbb_900100704",
    "name": "S+U Alexanderplatz [U5]",
    "x": 13.41311,
    "y": 52.521607
    }
},
{
    "dep": "2018-11-19T07:53:00",
    "Stn": {
    "id": "vbb_900100017",
    "name": "U Schillingstr.",
    "x": 13.421893,
    "y": 52.520313
    }
},
{
    "dep": "2018-11-19T07:55:00",
    "Stn": {
    "id": "vbb_900120006",
    "name": "U Strausberger Platz",
    "x": 13.432212,
    "y": 52.518029
    }
}
]
}
© www.soinside.com 2019 - 2024. All rights reserved.