Skip to content

Commit e7c5a2d

Browse files
committed
dynamically determine which copyrights should be included
1 parent 23944d4 commit e7c5a2d

File tree

1 file changed

+7
-5
lines changed
  • packages/compass-schema/src/components/coordinates-minichart

1 file changed

+7
-5
lines changed

packages/compass-schema/src/components/coordinates-minichart/utils.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'lodash';
12
import L from 'leaflet';
23

34
import { COPYRIGHT_URL } from './constants';
@@ -9,10 +10,12 @@ const thisYear = new Date().getFullYear();
910
* @returns {Array} Array of attribution objects { label, alt, boxes, minLevel, maxLevel }
1011
*/
1112
export async function _getHereTileBoxes() {
12-
const rawTileBoxes = await fetch(COPYRIGHT_URL).then((response) =>
13+
const copyrightData = await fetch(COPYRIGHT_URL).then((response) =>
1314
response.json()
1415
);
15-
const result = [...rawTileBoxes.copyrights.in, ...rawTileBoxes.copyrights.jp, ...rawTileBoxes.copyrights.dtm]
16+
const fields = copyrightData.resources.base.styles['lite.day'];
17+
const tileBoxes = Object.values(_.pick(copyrightData.copyrights, fields))
18+
.flat()
1619
.map((notice) => ({
1720
alt: notice.copyrightText,
1821
label: notice.label,
@@ -24,9 +27,8 @@ export async function _getHereTileBoxes() {
2427
L.latLng(box.north, box.east)
2528
)
2629
),
27-
}))
28-
.flat();
29-
return result;
30+
}));
31+
return tileBoxes;
3032
}
3133

3234
function cachedGetHereTileBoxes() {

0 commit comments

Comments
 (0)