Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这不起作用:
directionsDisplay.setDirections(response.routes[1]);
这有效:
directionsDisplay.setDirections(response);
你能解释一下这个原因吗?
您需要设置路线索引。要显示第二条路线,请使用:
var route_num = 1; var first_load = false; directionsDisplay.setRouteIndex(route_num); if (first_load) { // only execute this when the directions are first displayed directionsDisplay.setDirections(objRoutesResponse); }