How to use the @mapbox/mapbox-gl-style-spec/feature_filter function in @mapbox/mapbox-gl-style-spec

To help you get started, we’ve selected a few @mapbox/mapbox-gl-style-spec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geomoose / gm3 / src / gm3 / util.js View on Github external
export function filterFeatures(features, filter, inverse = true) {
    const new_features = [];

    // the createFilter function is from mapbox!
    // uses the mapbox gl style filters.
    let filter_function = function() { return true; };

    if (filter !== undefined && filter !== null ) {
        filter_function = createFilter(['all'].concat(filter));
    }

    for(const feature of features) {
        if(inverse !== filter_function(feature)) {
            new_features.push(feature);
        }
    }

    return new_features;
}