mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-06-09 17:00:25 +00:00
get styles from github
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -27,14 +27,12 @@ import ignFrTopo from './custom/ign-fr-topo.json';
|
|||||||
import ignFrPlan from './custom/ign-fr-plan.json';
|
import ignFrPlan from './custom/ign-fr-plan.json';
|
||||||
import ignFrSatellite from './custom/ign-fr-satellite.json';
|
import ignFrSatellite from './custom/ign-fr-satellite.json';
|
||||||
import bikerouterGravel from './custom/bikerouter-gravel.json';
|
import bikerouterGravel from './custom/bikerouter-gravel.json';
|
||||||
import topo from './custom/topo.json';
|
|
||||||
import satellite from './custom/satellite.json';
|
|
||||||
|
|
||||||
export const maptilerKeyPlaceHolder = 'MAPTILER_KEY';
|
export const maptilerKeyPlaceHolder = 'MAPTILER_KEY';
|
||||||
|
|
||||||
export const basemaps: { [key: string]: string | StyleSpecification } = {
|
export const basemaps: { [key: string]: string | StyleSpecification } = {
|
||||||
topo: topo as StyleSpecification,
|
topo: 'https://raw.githubusercontent.com/gpxstudio/styles/refs/heads/main/topo.json',
|
||||||
satellite: satellite as StyleSpecification,
|
satellite: 'https://raw.githubusercontent.com/gpxstudio/styles/refs/heads/main/satellite.json',
|
||||||
esriSatellite: {
|
esriSatellite: {
|
||||||
version: 8,
|
version: 8,
|
||||||
sources: {
|
sources: {
|
||||||
|
|||||||
@@ -91,6 +91,18 @@ export class StyleManager {
|
|||||||
let basemapStyle = basemaps.openStreetMap as maplibregl.StyleSpecification;
|
let basemapStyle = basemaps.openStreetMap as maplibregl.StyleSpecification;
|
||||||
try {
|
try {
|
||||||
basemapStyle = await this.get(basemapInfo);
|
basemapStyle = await this.get(basemapInfo);
|
||||||
|
for (const source in basemapStyle.sources) {
|
||||||
|
const src = basemapStyle.sources[source];
|
||||||
|
if (
|
||||||
|
src &&
|
||||||
|
typeof src === 'object' &&
|
||||||
|
'url' in src &&
|
||||||
|
typeof src.url === 'string' &&
|
||||||
|
src.url.includes(maptilerKeyPlaceHolder)
|
||||||
|
) {
|
||||||
|
src.url = src.url.replace(maptilerKeyPlaceHolder, this._maptilerKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
}
|
}
|
||||||
@@ -199,18 +211,6 @@ export class StyleManager {
|
|||||||
const style = await response.json();
|
const style = await response.json();
|
||||||
return style;
|
return style;
|
||||||
} else {
|
} else {
|
||||||
for (const source in styleInfo.sources) {
|
|
||||||
const src = styleInfo.sources[source];
|
|
||||||
if (
|
|
||||||
src &&
|
|
||||||
typeof src === 'object' &&
|
|
||||||
'url' in src &&
|
|
||||||
typeof src.url === 'string' &&
|
|
||||||
src.url.includes(maptilerKeyPlaceHolder)
|
|
||||||
) {
|
|
||||||
src.url = src.url.replace(maptilerKeyPlaceHolder, this._maptilerKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return styleInfo;
|
return styleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user