UNPKG

mobility-toolbox-js

Version:

Toolbox for JavaScript applications in the domains of mobility and logistics.

31 lines (30 loc) 952 B
import removeDuplicate from './removeDuplicate'; /** * Return the copyright a Maplibre map. * @param {maplibregl.Map} map A Maplibre map * @private */ const getMapGlCopyrights = (map) => { if (!map) { return []; } const { style } = map; if (!style) { return []; } const { sourceCaches } = style; let copyrights = []; Object.values(sourceCaches).forEach((value) => { var _a; if (value.used) { const source = value.getSource(); const attribution = (source === null || source === void 0 ? void 0 : source.attribution) || ((_a = source.options) === null || _a === void 0 ? void 0 : _a.attribution); if (attribution) { copyrights = copyrights.concat(attribution.replace(/&copy;/g, '©').split(/(<a.*?<\/a>)/)); } } }); return removeDuplicate(copyrights); }; export default getMapGlCopyrights;