Skip to content

Commit fa09d6d

Browse files
lerouxbgribnoysup
andauthored
fix(schema): update maps from map tile API v2 to raster tile API v3 COMPASS-8981 (#6729)
* Update maps from map tile API v2 to raster tile API v3 * Update packages/compass-schema/src/components/coordinates-minichart/utils.js Co-authored-by: Sergey Petushkov <[email protected]> * dynamically determine which copyrights should be included * Update packages/compass-schema/src/components/coordinates-minichart/utils.js Co-authored-by: Sergey Petushkov <[email protected]> * Revert "Update packages/compass-schema/src/components/coordinates-minichart/utils.js" This reverts commit 8713ed8. --------- Co-authored-by: Sergey Petushkov <[email protected]>
1 parent f995c75 commit fa09d6d

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22
const LIGHTMODE_TILE_URL =
3-
'https://compass-maps.mongodb.com/compass/maptile/reduced.day/{z}/{x}/{y}/512';
3+
'https://compass-maps.mongodb.com/compass/maptile/v3/lite.day/{z}/{x}/{y}/512';
44
const DARKMODE_TILE_URL =
5-
'https://compass-maps.mongodb.com/compass/maptile/reduced.night/{z}/{x}/{y}/512';
5+
'https://compass-maps.mongodb.com/compass/maptile/v3/lite.night/{z}/{x}/{y}/512';
66

77
// The copyright url for HERE maps, if we're using the default tile url
8-
const COPYRIGHT_URL = 'https://compass-maps.mongodb.com/compass/copyright';
8+
const COPYRIGHT_URL = 'https://compass-maps.mongodb.com/compass/copyright/v3';
99

1010
export { LIGHTMODE_TILE_URL, DARKMODE_TILE_URL, COPYRIGHT_URL };

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

Lines changed: 18 additions & 7 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,15 +10,25 @@ 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-
return rawTileBoxes.normal.map((attr) => ({
16-
...attr,
17-
boxes: attr.boxes.map((box) =>
18-
L.latLngBounds(L.latLng(box[0], box[1]), L.latLng(box[2], box[3]))
19-
),
20-
}));
16+
const fields = copyrightData.resources.base.styles['lite.day'];
17+
const tileBoxes = Object.values(_.pick(copyrightData.copyrights, fields))
18+
.flat()
19+
.map((notice) => ({
20+
alt: notice.copyrightText,
21+
label: notice.label,
22+
maxLevel: notice.maxLevel,
23+
minLevel: notice.minLevel,
24+
boxes: notice.boundingBoxes.map((box) =>
25+
L.latLngBounds(
26+
L.latLng(box.south, box.west),
27+
L.latLng(box.north, box.east)
28+
)
29+
),
30+
}));
31+
return tileBoxes;
2132
}
2233

2334
function cachedGetHereTileBoxes() {

0 commit comments

Comments
 (0)