Reputation: 181
I've found a great example of how to filter leaflet points with a slider.
I would like to use this, but without the MarkerCluster clustering.
But I'm getting a "too much recursion" error in JS. May I please ask what's wrong with my code:
var popplaces = new L.geoJson(exp_popplaces,{
onEachFeature: pop_popplaces,
pointToLayer: popplaces_marker
});
[..]
slidervar.noUiSlider.on('update', function( values, handle ) {
console.log(handle);
if (handle==0){
document.getElementById('input-number-min').value = values[0];
} else {
document.getElementById('input-number-max').value = values[1];
}
rangeMin = document.getElementById('input-number-min').value;
rangeMax = document.getElementById('input-number-max').value;
////first let's clear the layer:
//cluster_popplaces.clearLayers();
popplaces.clearLayers();
////and repopulate it
popplaces = new L.geoJson(exp_popplaces,{
onEachFeature: pop_popplaces,
filter:
function(feature, layer) {
return (feature.properties.pop_max <= rangeMax) && (feature.properties.pop_max >= rangeMin);
},
pointToLayer: popplaces_marker
})
//and back again into the cluster group
//cluster_popplaces.addLayer(popplaces);
popplaces.addLayer(popplaces);
});
Here is my full source: index_raw_cluster.html
Upvotes: 0
Views: 193
Reputation: 28
You can't add a var to itself:
popplaces.addLayer(popplaces);
this is indeed too much recursion.
Upvotes: 1