I want to make dynamic filter on Leaflet, but I got a little problem. so first this my dropdown:
<select id="selc">
<option value="baik">baik</option>
<option value="sedang">sedang</option>
<option value="berat">berat</option>
</select>
and this my filter:
filter: function(feature, layer) {
<?php
$asa = $this->db->query("SELECT du_kode,du_kondisi FROM data_umum inner join data_umum_head on data_umum.duh_id=data_umum_head.duh_id where data_umum_head.maplink_id = '$ml->maplink_id'")->result();
foreach($asa as $dew){ ?>
woe = <?= $dew->du_kode?>;
if(feature.properties.ID==woe){
wawa = '<?= $dew->du_kondisi?>';
$('#selc').on('change', function() {
console.log($('#selc').val(),feature.properties.ID,wawa);
if(wawa == $('#selc').val()){
return (feature.properties.ID)
}
});
}
<?php } ?>
},
My problem is why my on.change is not working to return (feature.properties.ID)
but if I do manually and change the code like this
filter: function(feature, layer) {
<?php
$asa = $this->db->query("
SELECT du_kode,du_kondisi FROM data_umum
inner join data_umum_head on
data_umum.duh_id=data_umum_head.duh_id where
data_umum_head.maplink_id = '$ml->maplink_id'")->result();
foreach($asa as $dew){ ?>
woe = '<?= $dew->du_kode?>';
if(feature.properties.ID==woe){
wawa = '<?= $dew->du_kondisi?>';
/*$('#selc').on('change', function() {
console.log($('#selc').val(),feature.properties.ID,wawa);
if(wawa == $('#selc').val()){
return (feature.properties.ID)
}
});
*/
console.log(wawa);
if(wawa == 'berat'){
return (feature.properties.ID)
}
}
<?php } ?>
},
This is the result I expected, but how can I use it with onchange?