过滤器在 Leaflet 中显示 "true" 而不是想要的标签

Filter shows "true" instead of wanted labels in Leaflet

过滤掉某些数字以在传单中显示为标签。下面的代码确实过滤正确,但它没有显示正确的标签,它在地图上显示“真”而不是想要的数字 650 到 699。 需要进行哪些更改才能显示属性标签而不是此过滤中的“true”?

var local_points = new L.layerGroup();

    function local (feature){
        var filter = (feature.properties.local >= 650 && feature.properties.local < 699)
        return filter;
    };

var collisionlocal = L.LayerGroup.collision({margin:5});

$.getJSON("/geodata/localID_points.geojson", function(json) {

var points = L.geoJSON.collision(null, {
    pointToLayer: function(feature,latlng){
    label3s = String('<span class="textLabelclass3small">' + local(feature) + '</span>')
return new L.marker(latlng, {
        icon:createLabelIcon("textLabelclass3small",label3s)
        });
        }
    });

    var createLabelIcon = function(labelClass,labelText){
        return L.divIcon({ 
            className: labelClass,
            html: labelText
            });
        };

points.addData(json);
collisionlocal.addLayer(points);
collisionlocal.addTo(local_points);

});

您需要将过滤器应用于 geoJson 调用,而不是在文本中:

var points = L.geoJSON.collision(null, {
    filter: local,
    pointToLayer: function(feature,latlng){
        label3s = String('<span class="textLabelclass3small">' + feature.properties.local + '</span>')
        return new L.marker(latlng, {
           icon:createLabelIcon("textLabelclass3small",label3s)
        });
     }
});