是否有人知道显示复选框列表的方法而不是选项,其工作方式与此相同?https://developers.google.com/maps/documentation/javascript/examples/directions-waypoints?hl=es-419
答案 0 :(得分:1)
只需检查哪些复选框,然后将航点值传递给directionsService。
航点(HTML):
<input type="checkbox" name="waypoints" value="montreal, quebec">Montreal, QBC<br/>
<input type="checkbox" name="waypoints" value="toronto, ont">Toronto, ONT<br/>
获取复选框值(Javascript):
var checkboxArray = document.querySelectorAll('input[type=checkbox]:checked');
有几种方法可以做到这一点,您可以在这里看到替代方案:
Getting all selected checkboxes in an array
这是一个工作样本小提琴: http://jsfiddle.net/mervinsamy/eb5t22fq/
来自示例代码: https://developers.google.com/maps/documentation/javascript/examples/directions-waypoints?hl=es-419