Google Maps API:如何获得公共交通工具的出发平台?

时间:2019-06-04 20:29:43

标签: android google-maps

我想在我的Android应用中显示像火车一样的公共交通出发平台。

数据可用,因为使用google maps网站向我显示了火车从哪个平台出发,但我还没有设法从DirectionsResult对象中检索此数据。

有人知道该怎么做吗?

更新: 尝试使用邮递员检索数据导致出现以下对象,因为您可以看到火车步骤没有发车平台数据,而该数据在Google Maps网站或应用本身中可用。

{
"geocoded_waypoints": [
    {
        "geocoder_status": "OK",
        "place_id": "ChIJeblWZV1vxkcRbk1MYz1wjbg",
        "types": [
            "bus_station",
            "establishment",
            "point_of_interest",
            "train_station",
            "transit_station"
        ]
    },
    {
        "geocoder_status": "OK",
        "place_id": "ChIJIxbYDbcJxkcRQtHfOo0b58o",
        "types": [
            "bus_station",
            "establishment",
            "point_of_interest",
            "subway_station",
            "train_station",
            "transit_station"
        ]
    }
],
"routes": [
    {
        "bounds": {
            "northeast": {
                "lat": 52.3793179,
                "lng": 5.1124581
            },
            "southwest": {
                "lat": 52.0894115,
                "lng": 4.8996663
            }
        },
        "copyrights": "Map data ©2019",
        "legs": [
            {
                "arrival_time": {
                    "text": "10:25am",
                    "time_zone": "Europe/Amsterdam",
                    "value": 1560846300
                },
                "departure_time": {
                    "text": "9:58am",
                    "time_zone": "Europe/Amsterdam",
                    "value": 1560844680
                },
                "distance": {
                    "text": "39.5 km",
                    "value": 39518
                },
                "duration": {
                    "text": "27 mins",
                    "value": 1620
                },
                "end_address": "Amsterdam Centraal, Stationsplein, 1012 AB Amsterdam, Netherlands",
                "end_location": {
                    "lat": 52.3781611,
                    "lng": 4.8998801
                },
                "start_address": "Utrecht Central Station, Stationshal 12 12, 3511 CE Utrecht, Netherlands",
                "start_location": {
                    "lat": 52.0894115,
                    "lng": 5.1124581
                },
                "steps": [
                    {
                        "distance": {
                            "text": "1 m",
                            "value": 0
                        },
                        "duration": {
                            "text": "1 min",
                            "value": 0
                        },
                        "end_location": {
                            "lat": 52.0894115,
                            "lng": 5.1124581
                        },
                        "html_instructions": "Walk to Utrecht Central Station",
                        "polyline": {
                            "points": "yu||H{oe^"
                        },
                        "start_location": {
                            "lat": 52.0894115,
                            "lng": 5.1124581
                        },
                        "steps": [
                            {
                                "distance": {
                                    "text": "1 m",
                                    "value": 0
                                },
                                "duration": {
                                    "text": "1 min",
                                    "value": 0
                                },
                                "end_location": {
                                    "lat": 52.0894115,
                                    "lng": 5.1124581
                                },
                                "polyline": {
                                    "points": "yu||H{oe^"
                                },
                                "start_location": {
                                    "lat": 52.0894115,
                                    "lng": 5.1124581
                                },
                                "travel_mode": "WALKING"
                            }
                        ],
                        "travel_mode": "WALKING"
                    },
                    {
                        "distance": {
                            "text": "39.5 km",
                            "value": 39518
                        },
                        "duration": {
                            "text": "27 mins",
                            "value": 1620
                        },
                        "end_location": {
                            "lat": 52.3792931,
                            "lng": 4.8996663
                        },
                        "html_instructions": "Train towards Alkmaar",
                        "polyline": {
                            "points": "ww||Hu{d^u@eDA@qb@td@eJz^ac@ry@ijEr}IouAltCeWlo@}PhYyQvQkQ`KmRdFo[|Bi^qA_oJ}dBmOaBiVHeZhG}VnNubEhkDusB~eBwuAhmA_fA|bAk\\t]waAx{@cWnOmT`Ii@Ru[lRaGXyF}BqGyKiTadA_L}MuYc@{]kMgJbBsGpH{Nhs@uGfw@O~i@cNvk@DB"
                        },
                        "start_location": {
                            "lat": 52.0897216,
                            "lng": 5.1092273
                        },
                        "transit_details": {
                            "arrival_stop": {
                                "location": {
                                    "lat": 52.3792931,
                                    "lng": 4.8996663
                                },
                                "name": "Amsterdam Centraal"
                            },
                            "arrival_time": {
                                "text": "10:25am",
                                "time_zone": "Europe/Amsterdam",
                                "value": 1560846300
                            },
                            "departure_stop": {
                                "location": {
                                    "lat": 52.0897216,
                                    "lng": 5.1092273
                                },
                                "name": "Utrecht Central Station"
                            },
                            "departure_time": {
                                "text": "9:58am",
                                "time_zone": "Europe/Amsterdam",
                                "value": 1560844680
                            },
                            "headsign": "Alkmaar",
                            "line": {
                                "agencies": [
                                    {
                                        "name": "NS",
                                        "phone": "011 31 30 751 5155",
                                        "url": "http://www.ns.nl/"
                                    }
                                ],
                                "name": "Alkmaar <-> Maastricht IC800",
                                "short_name": "Intercity",
                                "vehicle": {
                                    "icon": "//maps.gstatic.com/mapfiles/transit/iw2/6/rail2.png",
                                    "name": "Train",
                                    "type": "HEAVY_RAIL"
                                }
                            },
                            "num_stops": 2,
                            "trip_short_name": "828"
                        },
                        "travel_mode": "TRANSIT"
                    },
                    {
                        "distance": {
                            "text": "1 m",
                            "value": 0
                        },
                        "duration": {
                            "text": "1 min",
                            "value": 0
                        },
                        "end_location": {
                            "lat": 52.3781611,
                            "lng": 4.8998801
                        },
                        "html_instructions": "Walk to Amsterdam Centraal, Stationsplein, 1012 AB Amsterdam, Netherlands",
                        "polyline": {
                            "points": "obu~Hg_|\\"
                        },
                        "start_location": {
                            "lat": 52.3781611,
                            "lng": 4.8998801
                        },
                        "steps": [
                            {
                                "distance": {
                                    "text": "1 m",
                                    "value": 0
                                },
                                "duration": {
                                    "text": "1 min",
                                    "value": 0
                                },
                                "end_location": {
                                    "lat": 52.3781611,
                                    "lng": 4.8998801
                                },
                                "polyline": {
                                    "points": "obu~Hg_|\\"
                                },
                                "start_location": {
                                    "lat": 52.3781611,
                                    "lng": 4.8998801
                                },
                                "travel_mode": "WALKING"
                            }
                        ],
                        "travel_mode": "WALKING"
                    }
                ],
                "traffic_speed_entry": [],
                "via_waypoint": []
            }
        ],
        "overview_polyline": {
            "points": "yu||H{oe^}@dSu@eDsb@vd@eJz^ac@ry@y`H`sNeWlo@}PhYyQvQkQ`KmRdFo[|Bi^qA_oJ}dBmOaBiVHeZhG}VnNubEhkDusB~eBwuAhmA_fA|bAk\\t]waAx{@cWnOmT`Ii@Ru[lRaGXyF}BqGyKiTadA_L}MuYc@{]kMgJbBsGpH{Nhs@uGfw@O~i@cNvk@DB`Fi@"
        },
        "summary": "",
        "warnings": [
            "Walking directions are in beta. Use caution – This route may be missing sidewalks or pedestrian paths."
        ],
        "waypoint_order": []
    }
],
"status": "OK"

}

1 个答案:

答案 0 :(得分:1)

很遗憾,此信息目前无法通过Directions API获得。 Google问题跟踪器中有一项功能请求,用于添加2016年创建的登机平台信息:

https://issuetracker.google.com/issues/35829155

看来Google对此任务没有设置高优先级。随时在Google问题跟踪器中为功能请求加注星标,以添加您的投票。希望有一天Google会实施它。