I have a map with travel routes on it, they are divided into colours according to the type of transport. These lines had a weight of 2 and I increased them to 4. But I want to make them flexible for the user by means of a slider (rangeCtrl). I have tried the following in some different variations:
<script>
var linekleur = '<?php printf($KC) ?>';
if (linekleur == "T") {
var polyline_options = {
weight: 4,
opacity: 1,
dashArray: '2, 8',
lineCap: 'square',
color: '<?php printf($$KlCo) ?>'
};
}else{
var polyline_options = {
weight: 4,
opacity: 1,
color: '<?php printf($$KlCo) ?>'
};
};
var latlngs = [<?php printf($xyz_range1) ?>];
var polyline = L.polyline(latlngs, polyline_options).bindLabel('<?php printf($LineInfo) ?>').addTo(daggroep_<?php printf($Reisdag) ?>);
function SetupPolylineOptions(value) {
polyline.setStyle(weight);
};
</script>
I am using this command to send a value to the function.:
<input id='rangeCtrl' type='range' min='1' max='10' step='1' value='8' title='weight' width='20px' onchange='SetupPolylineOptions(value)' />
See also: Example of map Look on the right in the Layer-menu
I hope the code below helps. I will not explain because the code is very simple.
As for your code, maybe the following modification will help
EDIT: SECOND SOLUTION