没有合法的方法。论坛上有一些笔记,人们使用Yandex地图的内部api,但据我所知,他们很快被Yandex团队禁止。Yandex不会从地图中单独提供任何交通数据。我建议您查看谷歌地图Api,在那里您可以获得您指定路线的交通信息。例子:
final String baseUrl = "http://maps.googleapis.com/maps/api/directions/json";// path to Geocoding API via http
final Map<String, String> params = new HashMap<String, String>();
params.put("sensor", "false");// if data for geocoding comes from device with sensor
params.put("language", "en");
params.put("mode", "driving");// move mode, could be driving, walking, bicycling
params.put("origin", "Russia, Moscow, Poklonnaya str., 12");// start point of route as address or text value of lon and lat
params.put("destination", "Russia, Moscow, metro station Park Pobedy");// the same for end point
final String url = baseUrl + '?' + encodeParams(params);// generate final url
final JSONObject response = JsonReader.read(url);// perform request and read answer where we could also get coordinates
//results[0]/geometry/location/lng and results[0]/geometry/location/lat
JSONObject location = response.getJSONArray("routes").getJSONObject(0);
location = location.getJSONArray("legs").getJSONObject(0);
final String distance = location.getJSONObject("distance").getString("text"); // get distance for route
final String duration = location.getJSONObject("duration").getString("text"); // get duration for route
有关更多信息,请查看
https://developers.google.com/maps/