function getStyleOpacities(map, metadataKey) {
    const {_layers, _order} = map.style,
        propMapping = {
            'background-underground': 1,
            'building-underground-underground': ['interpolate', ['linear'], ['zoom'], 14.5, 0, 15, 1]
        },
        opacities = [];

    _order.map(id => _layers[id]).filter(({metadata}) =>
        metadata && metadata[metadataKey]
    ).forEach(({id, type, metadata}) => {
        if (type === 'custom') {
            opacities.push({id, metadata});
            return;
        }

        const key = `${type}-opacity`,
            prop = propMapping[id] || valueOrDefault(map.getPaintProperty(id, key), 1);

        if (!isNaN(prop)) {
            opacities.push({id, key, opacity: prop, metadata});
        } else if (prop.stops) {
            const opacity = [];

            prop.stops.forEach((item, index) => {
                opacity.push({index, value: item[1]});
            });
            opacities.push({id, key, opacity, metadata});
        } else if (prop[0] === 'case' || prop[0] === 'interpolate') {
            const opacity = [];

            prop.forEach((item, index) => {
                if (index % 2 === 0 && !isNaN(item)) {
                    opacity.push({index, value: item});
                }
            });
            opacities.push({id, key, opacity, metadata});
        }
    });
    return opacities;
}
Returns an array of the style opacity information retrieved from map layers.
@param {mapboxgl.Map} map - Mapbox's Map object
@param {string} metadataKey - Metadata key to filter
@returns {Array<Object>} Array of the style opacity objects