Skip to content

Commit

Permalink
Add Tracestrack Topo layer
Browse files Browse the repository at this point in the history
  • Loading branch information
cdauth committed Nov 28, 2024
1 parent 7b3dc10 commit 5414b11
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 5 deletions.
7 changes: 6 additions & 1 deletion config.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@
# Lima Labs provides nice double resolution layers.
# If this is defined, they are used as the default layer instead of Mapnik.
# Get an API key here: https://maps.lima-labs.com/
#LIMA_LABS_TOKEN=
#LIMA_LABS_TOKEN=

# Tracestrack provides a nice topographic map.
# If this is defined, the Tracestrack Topo map style will be available.
# Get an API key here: https://tracestrack.com/
#TRACESTRACK_TOKEN=
4 changes: 3 additions & 1 deletion docs/src/developers/leaflet/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ L.control.layers(byName(layers.baseLayers), byName(layers.overlays)).addTo(map);

There are some global layer options that change the behaviour of the available layers:
* `limaLabsToken`: A [Lima Labs](https://maps.lima-labs.com/) API token. If defined, the Lima Labs layer will be available and used as the default layer instead of Mapnik. Lima Labs layers are very similar to Mapnik in style, but they are double resolution (so they don’t look pixely on high-resolution screens) and have English place names in addition to the local language.
* `tracestrackToken`: A [Tracestrack](https://tracestrack.com/) API token. If defined, the Tracestrack Topo map style will be available.

To set the global layer options, use the `setLayerOptions()` function:
```javascript
import { setLayerOptions } from "facilmap-leaflet";

setLayerOptions({
limaLabsToken: "..."
limaLabsToken: "...",
tracestrackToken: "..."
});
```

Expand Down
1 change: 1 addition & 0 deletions docs/src/developers/server/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The config of the FacilMap server can be set either by using environment variabl
| `MAXMIND_USER_ID` | | | [MaxMind user ID](https://www.maxmind.com/en/geolite2/signup). |
| `MAXMIND_LICENSE_KEY` | | | MaxMind license key. |
| `LIMA_LABS_TOKEN` | | | [Lima Labs](https://maps.lima-labs.com/) API key |
| `TRACESTRACK_TOKEN` | | | [Tracestrack](https://tracestrack.com/) API key |
| `HIDE_COMMERCIAL_MAP_LINKS` | | | Set to `1` to hide the links to Google/Bing Maps in the “Map style” menu. |
| `CUSTOM_CSS_FILE` | | | The path of a CSS file that should be included ([see more details below](#custom-css-file)). |
| `NOMINATIM_URL` | | `https://nominatim.openstreetmap.org` | The URL to the Nominatim server (used to search for places). |
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/map/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ if ('serviceWorker' in navigator && location.hostname !== "localhost") {
}

setLayerOptions({
limaLabsToken: config.limaLabsToken
limaLabsToken: config.limaLabsToken,
tracestrackToken: config.tracestrackToken
});

const queryParams = decodeQueryString(location.search);
Expand Down
2 changes: 2 additions & 0 deletions leaflet/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"map1-attribution": "© [Map1.eu](http://map1.eu/) / [OSM-Mitwirkende](https://www.openstreetmap.org/copyright/de)",
"topo-name": "OpenTopoMap",
"topo-attribution": "© [OpenTopoMap](https://opentopomap.org/) ([CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/)) / [OSM-Mitwirkende](https://www.openstreetmap.org/copyright/de)",
"trto-name": "Tracestrack Topo",
"trto-attribution": "Daten: © [OSM-Mitwirkende](https://www.openstreetmap.org/copyright/de), [SRTM](http://viewfinderpanoramas.org/), [GEBCO](https://www.gebco.net/), [SONNY's LiDAR DTM](https://sonny.4lima.de/), [NASADEM](https://portal.opentopography.org/datasetMetadata?otCollectionID=OT.032021.4326.2), [ESA WorldCover](https://worldcover2021.esa.int/); Karte © [Tracestrack](https://www.tracestrack.com/)",
"cyco-name": "CyclOSM",
"cyco-attribution": "© [CyclOSM](https://www.cyclosm.org/) / [OSM-Mitwirkende](https://www.openstreetmap.org/copyright/de)",
"ocyc-name": "OpenCycleMap",
Expand Down
4 changes: 3 additions & 1 deletion leaflet/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"map1-name": "Map1.eu",
"map1-attribution": "© [Map1.eu](http://map1.eu/) / [OSM Contributors](https://www.openstreetmap.org/copyright)",
"topo-name": "OpenTopoMap",
"topo-attribution": "© [OpenTopoMap](https://opentopomap.org/) ([CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/)) / [OSM Contributors](https://www.openstreetmap.org/copyright)",
"topo-attribution": "Data: © [OpenTopoMap](https://opentopomap.org/) ([CC-BY-SA](https://creativecommons.org/licenses/by-sa/3.0/)) / [OSM Contributors](https://www.openstreetmap.org/copyright)",
"trto-name": "Tracestrack Topo",
"trto-attribution": "© [OSM contributors](https://www.openstreetmap.org/copyright), [SRTM](http://viewfinderpanoramas.org/), [GEBCO](https://www.gebco.net/), [SONNY's LiDAR DTM](https://sonny.4lima.de/), [NASADEM](https://portal.opentopography.org/datasetMetadata?otCollectionID=OT.032021.4326.2), [ESA WorldCover](https://worldcover2021.esa.int/); Maps © [Tracestrack](https://www.tracestrack.com/)",
"cyco-name": "CyclOSM",
"cyco-attribution": "© [CyclOSM](https://www.cyclosm.org/) / [OSM Contributors](https://www.openstreetmap.org/copyright)",
"ocyc-name": "OpenCycleMap",
Expand Down
9 changes: 9 additions & 0 deletions leaflet/src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export function createDefaultLayers(): Layers & { fallbackLayer: string | undefi
noWrap: true
})),

...(layerOptions.tracestrackToken ? {
TrTo: fixAttribution(tileLayer(`https://tile.tracestrack.com/topo__/{z}/{x}/{y}.png?key=${encodeURIComponent(layerOptions.tracestrackToken)}`, {
...fmName(() => getI18n().t("layers.trto-name")),
...attribution(() => getI18n().t("layers.trto-attribution")),
noWrap: true
}))
} : {}),

CycO: fixAttribution(tileLayer("https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png", {
...fmName(() => getI18n().t("layers.cyco-name")),
...attribution(() => getI18n().t("layers.cyco-attribution")),
Expand Down Expand Up @@ -146,6 +154,7 @@ export function setLayers(create: typeof createDefaultLayers): void {

export interface LayerOptions {
limaLabsToken?: string;
tracestrackToken?: string;
}

let layerOptions: LayerOptions = {};
Expand Down
4 changes: 3 additions & 1 deletion server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Config {
maxmindUserId?: string;
maxmindLicenseKey?: string;
limaLabsToken?: string;
tracestrackToken?: string;
/** Hide the "Open this on Google/Bing Maps" links in the map style menu */
hideCommercialMapLinks?: boolean;
customCssFile?: string;
Expand Down Expand Up @@ -61,7 +62,8 @@ const config: Config = {
maxmindUserId: process.env.MAXMIND_USER_ID || "",
maxmindLicenseKey: process.env.MAXMIND_LICENSE_KEY || "",

limaLabsToken: process.env.LIMA_LABS_TOKEN || "", // Get a token on https://maps.lima-labs.com/,
limaLabsToken: process.env.LIMA_LABS_TOKEN || "", // Get a token on https://maps.lima-labs.com/
tracestrackToken: process.env.TRACESTRACK_TOKEN || "", // Get a token on https://tracestrack.com/

hideCommercialMapLinks: process.env.HIDE_COMMERCIAL_MAP_LINKS === "1",

Expand Down
1 change: 1 addition & 0 deletions server/src/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function getInjectedConfig(): InjectedConfig {
openElevationMaxBatchSize: config.openElevationMaxBatchSize,
nominatimUrl: config.nominatimUrl,
limaLabsToken: config.limaLabsToken,
tracestrackToken: config.tracestrackToken,
hideCommercialMapLinks: config.hideCommercialMapLinks,
supportsRoutes: !!config.mapboxToken || !!config.orsToken,
supportsAdvancedRoutes: !!config.orsToken
Expand Down
1 change: 1 addition & 0 deletions utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface InjectedConfig {
openElevationMaxBatchSize: number;
nominatimUrl: string;
limaLabsToken?: string;
tracestrackToken?: string;
hideCommercialMapLinks?: boolean;
supportsRoutes: boolean;
supportsAdvancedRoutes: boolean;
Expand Down

0 comments on commit 5414b11

Please sign in to comment.