3

I have a leftleat map and i would like to filter the featuregroup i am displaying.

exp_colJSON = new L.geoJson(exp_col,{
onEachFeature: pop_col,
pointToLayer: function (feature, latlng) {  
    return L.circleMarker(latlng, {
        radius: feature.properties.radius_qgis2leaf,
        fillColor: feature.properties.color_qgis2leaf,
        color: feature.properties.borderColor_qgis2leaf,
        weight: 1,
        opacity: feature.properties.transp_qgis2leaf,
        fillOpacity: feature.properties.transp_qgis2leaf    }).addTo(map).bindLabel(Autolinker.link(String(feature.properties['name'])), { noHide: true });
    }
});

feature_group.addLayer(exp_colJSON);
exp_colJSON.addTo(map);

I also added a combobox and i would like to filter the layer's features by the value selected in the combobox. I want to campare the selected value in the combobox with the "level" property of every feature in the layer.

I have coded so far:

$(document).ready(function(){ // ran when the document is fully loaded
  // retrieve the jQuery wrapped dom object identified by the selector 
  var exp_getxocolcolegiosJSON = {};
  var sel = $('#niveles');
  // assign a change listener to it
  sel.change(function(){ //inside the listener
    // retrieve the value of the object firing the event (referenced by this)
    var value = $(this).val();

    //do whatever needed here to filter the layer

    L.geoJson(exp_col, {
    filter: function(feature, layer) {
         return(feature.properties.nivelmodelo.match(/.*value.*\/)) 
     }
    }).addTo(map);

    // I know this has no sense but i don't know how to code it

  }); // close the change listener
}); // close the ready listener 

Regards,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.