私はサイトで作業していて、アイコンを使用して移動モードを選択したいのですが、機能していますが、選択入力でしか機能しません。ボタンで使用するように変更する方法はありますか?
前もって感謝します!
関数:
function calcRoute() {
var selectedMode = document.getElementById("mode").value;
var request = {
origin: thuis,
destination: kabk,
// Note that Javascript allows us to access the constant
// using square brackets and a string value as its
// "property."
travelMode: google.maps.TravelMode[selectedMode]
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
HTML - 入力の選択
<select id="mode" onchange="calcRoute();">
<option value="DRIVING">Driving</option>
<option value="WALKING">Walking</option>
</select>
HTML - ボタン入力 (?)
<form id="mode">
<input type="button" onchange="calcRoute();" value="DRIVING">
<input type="button" onchange="calcRoute();" value="WALKING">
</form>