s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
24 lines (23 loc) • 839 B
JavaScript
const URL_MAP = {
s2maps: 'https://api.s2maps.com',
opens2: 'https://api.opens2.com',
mapbox: 'https://api.mapbox.com',
apiURL: 'https://api.opens2.com',
baseURL: 'https://opens2.com',
};
/**
* Adjust a URL either using:
* the URL_MAP (replace "s2maps://", "opens2://", or "mapbox://")
* the apiURL (replace "apiURL://") or baseURL (replace "baseURL://")
* which is defined by the user in the {@link MapOptions} `urlMap` property.
* @param input - the input URL
* @param userMap - the user defined guide on how to replace the URL_MAP
* @returns the adjusted URL
*/
export function adjustURL(input, userMap = {}) {
// replace all URL_MAP instances
for (const [key, value] of Object.entries({ ...URL_MAP, ...userMap })) {
input = input.replace(`${key}://`, `${value}/`);
}
return input;
}