Does anyone know a way to show a list of checkboxes instead options, that works the same way as this?https://developers.google.com/maps/documentation/javascript/examples/directions-waypoints?hl=es-419
Asked
Active
Viewed 76 times
-2
-
1Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – Spoody Apr 16 '18 at 22:36
1 Answers
1
It is just a matter of getting which checkboxes are checked and then passing the waypoint values to the directionsService.
Waypoints(HTML):
<input type="checkbox" name="waypoints" value="montreal, quebec">Montreal, QBC<br/>
<input type="checkbox" name="waypoints" value="toronto, ont">Toronto, ONT<br/>
Get checkbox values (Javascript):
var checkboxArray = document.querySelectorAll('input[type=checkbox]:checked');
There are several ways to do this, you can see alternatives here:
Getting all selected checkboxes in an array
Here is a working sample fiddle: http://jsfiddle.net/mervinsamy/eb5t22fq/
from the sample code in: https://developers.google.com/maps/documentation/javascript/examples/directions-waypoints?hl=es-419

Mervin Samy
- 366
- 4
- 13