function calculateExtent(map, layersWithSources, { limitToFeatures } = {}) {
        const extent = ol.extent.createEmpty();
        _.each(layersWithSources, ({ layer, layers, source }) => {
            (layers ? layers : [layer]).forEach(layer => {
                if (source && source.getExtent && source.getFeatureById && layer.getVisible()) {
                    const hasCustomFn = _.isFunction(source.getCustomExtent);
                    const limit = limitToFeatures && limitToFeatures.reduce((list, feature) => {
                        if (source.getFeatureById(feature.getId())) {
                            list.push(feature)
                            if (!hasCustomFn) {
                                const featureExtent = feature.getGeometry().getExtent();
                                if (!ol.extent.isEmpty(featureExtent)) {
                                    ol.extent.extend(extent, featureExtent);
                                }
                            }
                        }
                        return list;
                    }, [])
                    if (hasCustomFn) {
                        ol.extent.extend(extent, source.getCustomExtent(limit));
                    } else if (!limitToFeatures && _.isFunction(source.getExtent)) {
                        ol.extent.extend(extent, source.getExtent());
                    }
                }
            })
        })
        return extent;
    }
// also uses custom extent function from layer extensions.
also uses custom extent function from layer extensions.
also uses custom extent function from layer extensions .
function calculateExtent(map, layersWithSources, { limitToFeatures } = {}) {
        const extent = ol.extent.createEmpty();
        _.each(layersWithSources, ({ layer, layers, source }) => {
            (layers ? layers : [layer]).forEach(layer => {
                if (source && source.getExtent && source.getFeatureById && layer.getVisible()) {
                    const hasCustomFn = _.isFunction(source.getCustomExtent);
                    const limit = limitToFeatures && limitToFeatures.reduce((list, feature) => {
                        if (source.getFeatureById(feature.getId())) {
                            list.push(feature)
                            if (!hasCustomFn) {
                                const featureExtent = feature.getGeometry().getExtent();
                                if (!ol.extent.isEmpty(featureExtent)) {
                                    ol.extent.extend(extent, featureExtent);
                                }
                            }
                        }
                        return list;
                    }, [])
                    if (hasCustomFn) {
                        ol.extent.extend(extent, source.getCustomExtent(limit));
                    } else if (!limitToFeatures && _.isFunction(source.getExtent)) {
                        ol.extent.extend(extent, source.getExtent());
                    }
                }
            })
        })
        return extent;
    }
function calculateExtent ( map , layersWithSources , { limitToFeatures } = { } ) { const extent = ol . extent . createEmpty ( ) ; _ . each ( layersWithSources , ( { layer , layers , source } ) => { ( layers ? layers : [ layer ] ) . forEach ( layer => { if ( source && source . getExtent && source . getFeatureById && layer . getVisible ( ) ) { const hasCustomFn = _ . isFunction ( source . getCustomExtent ) ; const limit = limitToFeatures && limitToFeatures . reduce ( ( list , feature ) => { if ( source . getFeatureById ( feature . getId ( ) ) ) { list . push ( feature ) if ( ! hasCustomFn ) { const featureExtent = feature . getGeometry ( ) . getExtent ( ) ; if ( ! ol . extent . isEmpty ( featureExtent ) ) { ol . extent . extend ( extent , featureExtent ) ; } } } return list ; } , [ ] ) if ( hasCustomFn ) { ol . extent . extend ( extent , source . getCustomExtent ( limit ) ) ; } else if ( ! limitToFeatures && _ . isFunction ( source . getExtent ) ) { ol . extent . extend ( extent , source . getExtent ( ) ) ; } } } ) } ) return extent ; }
also uses custom extent function from layer extensions.
also uses custom extent function from layer extensions .