Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
const LIGHTMODE_TILE_URL =
'https://compass-maps.mongodb.com/compass/maptile/reduced.day/{z}/{x}/{y}/512';
'https://compass-maps.mongodb.com/compass/maptile/v3/lite.day/{z}/{x}/{y}/512';
const DARKMODE_TILE_URL =
'https://compass-maps.mongodb.com/compass/maptile/reduced.night/{z}/{x}/{y}/512';
'https://compass-maps.mongodb.com/compass/maptile/v3/lite.night/{z}/{x}/{y}/512';

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

export { LIGHTMODE_TILE_URL, DARKMODE_TILE_URL, COPYRIGHT_URL };
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash';
import L from 'leaflet';

import { COPYRIGHT_URL } from './constants';
Expand All @@ -9,15 +10,25 @@ const thisYear = new Date().getFullYear();
* @returns {Array} Array of attribution objects { label, alt, boxes, minLevel, maxLevel }
*/
export async function _getHereTileBoxes() {
const rawTileBoxes = await fetch(COPYRIGHT_URL).then((response) =>
const copyrightData = await fetch(COPYRIGHT_URL).then((response) =>
response.json()
);
return rawTileBoxes.normal.map((attr) => ({
...attr,
boxes: attr.boxes.map((box) =>
L.latLngBounds(L.latLng(box[0], box[1]), L.latLng(box[2], box[3]))
),
}));
const fields = copyrightData.resources.base.styles['lite.day'];
const tileBoxes = Object.values(_.pick(copyrightData.copyrights, fields))
.flat()
.map((notice) => ({
alt: notice.copyrightText,
label: notice.label,
maxLevel: notice.maxLevel,
minLevel: notice.minLevel,
boxes: notice.boundingBoxes.map((box) =>
L.latLngBounds(
L.latLng(box.south, box.west),
L.latLng(box.north, box.east)
)
),
}));
return tileBoxes;
}

function cachedGetHereTileBoxes() {
Expand Down
Loading