Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(map): add token config for MapLibre/MapTiler

Timothy Yin9e7a3944802f
diff --git a/README.md b/README.md
index c5631e78..2f80fd28 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ We recommend deploying with the prebuilt Docker image. [View the image on ghcr](
Create a `.env` file and configure environment variables.
-Below is a **minimal configuration** example. For complete configuration options, see [.env.example](./.env.example):
+Below is a **minimal configuration** example. For complete configuration options, see [Configuration Guide](https://chronoframe.bh8.ga/guide/configuration.html):
```bash
# Admin email (required)
@@ -60,8 +60,13 @@ NUXT_PUBLIC_APP_SLOGAN=
NUXT_PUBLIC_APP_AUTHOR=
NUXT_PUBLIC_APP_AVATAR_URL=
-# Mapbox public token (required for map UI)
+# Map provider (maplibre/mapbox)
+NUXT_PUBLIC_MAP_PROVIDER=maplibre
+# MapTiler access token for MapLibre
+NUXT_PUBLIC_MAP_MAPLIBRE_TOKEN=
+# Mapbox access token for Mapbox
NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN=
+
# Mapbox unrestricted token (optional, reverse geocoding)
NUXT_MAPBOX_ACCESS_TOKEN=
diff --git a/README_zh.md b/README_zh.md
index 500e4ad7..223b0dd6 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -44,7 +44,7 @@
创建 `.env` 文件并配置。
-下面是**最小化配置**示例,完整的配置项参考 [.env.example](./.env.example):
+下面是**最小化配置**示例,完整的配置项参考 [配置指南](https://chronoframe.bh8.ga/zh/guide/configuration.html):
```bash
# 管理员邮箱(必须)
@@ -60,8 +60,13 @@ NUXT_PUBLIC_APP_SLOGAN=
NUXT_PUBLIC_APP_AUTHOR=
NUXT_PUBLIC_APP_AVATAR_URL=
-# Mapbox 公共访问令牌(地图 UI,必须)
+# 地图提供器 (maplibre/mapbox)
+NUXT_PUBLIC_MAP_PROVIDER=maplibre
+# 使用 MapLibre 需要 MapTiler 访问令牌
+NUXT_PUBLIC_MAP_MAPLIBRE_TOKEN=
+# 使用 Mapbox 需要 Mapbox 访问令牌
NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN=
+
# Mapbox 无域名限制令牌(反向地理编码,可选)
NUXT_MAPBOX_ACCESS_TOKEN=
diff --git a/app/assets/mapStyles/chronoframe_dark.json b/app/assets/mapStyles/chronoframe_dark.json
index bbfc6001..bcc28ba7 100644
--- a/app/assets/mapStyles/chronoframe_dark.json
+++ b/app/assets/mapStyles/chronoframe_dark.json
@@ -15,11 +15,11 @@
"sources": {
"openmaptiles": {
"type": "vector",
- "url": "https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL"
+ "url": "https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key="
}
},
"sprite": "https://openmaptiles.github.io/maptiler-basic-gl-style/sprite",
- "glyphs": "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=get_your_own_OpIi9ZULNHzrESv6T2vL",
+ "glyphs": "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=",
"layers": [
{
"id": "background",
diff --git a/app/assets/mapStyles/chronoframe_light.json b/app/assets/mapStyles/chronoframe_light.json
index 5b8b2d81..ede84d5a 100644
--- a/app/assets/mapStyles/chronoframe_light.json
+++ b/app/assets/mapStyles/chronoframe_light.json
@@ -15,11 +15,11 @@
"sources": {
"openmaptiles": {
"type": "vector",
- "url": "https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL"
+ "url": "https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key="
}
},
"sprite": "https://openmaptiles.github.io/maptiler-basic-gl-style/sprite",
- "glyphs": "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=get_your_own_OpIi9ZULNHzrESv6T2vL",
+ "glyphs": "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=",
"layers": [
{
"id": "background",
diff --git a/app/components/map/Provider.vue b/app/components/map/Provider.vue
index 7715c2c2..68b2eb29 100644
--- a/app/components/map/Provider.vue
+++ b/app/components/map/Provider.vue
@@ -40,11 +40,20 @@ const mapStyle = computed(() => {
if (provider.value === 'mapbox') {
return mapConfig.mapbox.style || `mapbox://styles/mapbox/standard`
} else {
+ const styleConfig =
+ colorMode.value === 'dark' ? ChronoFrameDarkStyle : ChronoFrameLightStyle
return (
mapConfig.maplibre.style ||
- ((colorMode.value === 'dark'
- ? ChronoFrameDarkStyle
- : ChronoFrameLightStyle) as StyleSpecification)
+ ({
+ ...styleConfig,
+ sources: {
+ openmaptiles: {
+ ...styleConfig.sources?.openmaptiles,
+ url: `https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key=${mapConfig.maplibre.token}`,
+ },
+ },
+ glyphs: `https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=${mapConfig.maplibre.token}`,
+ } as StyleSpecification)
)
}
})
diff --git a/docs/configuration/map-providers.md b/docs/configuration/map-providers.md
index 5a429b2b..770b9af4 100644
--- a/docs/configuration/map-providers.md
+++ b/docs/configuration/map-providers.md
@@ -2,17 +2,18 @@
ChronoFrame supports two types of map providers. You can choose the one that best fits your needs.
-| Provider | Supported | Extra Configuration | Features |
-| ---------------------- | :-------: | ------------------- | ------------------------------------- |
-| [MapLibre](#maplibre) | ✅ | None | Free and open-source, supports custom styles |
-| [Mapbox](#mapbox) | ✅ | Mapbox Access Token | Free tier, better renderer performance |
+| Provider | Supported | Extra Configuration | Features |
+| --------------------- | :-------: | --------------------- | -------------------------------------------- |
+| [MapLibre](#maplibre) | ✅ | MapTiler Access Token | Free and open-source, supports custom styles |
+| [Mapbox](#mapbox) | ✅ | Mapbox Access Token | Free tier, better renderer performance |
## MapLibre
-To use MapLibre as the map provider, simply configure it as follows—no additional setup is required:
+To use MapLibre as the map provider, you need a [MapTiler Access Token](https://cloud.maptiler.com/account/keys/).
```bash
NUXT_PUBLIC_MAP_PROVIDER=maplibre
+NUXT_PUBLIC_MAP_MAPLIBRE_TOKEN=your_maplibre_access_token
```
### Custom Styles
diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md
index 06687cc9..046c1d98 100644
--- a/docs/guide/getting-started.md
+++ b/docs/guide/getting-started.md
@@ -57,6 +57,13 @@ NUXT_PUBLIC_APP_SLOGAN=
NUXT_PUBLIC_APP_AUTHOR=
NUXT_PUBLIC_APP_AVATAR_URL=
+# Map provider (maplibre/mapbox)
+NUXT_PUBLIC_MAP_PROVIDER=maplibre
+# MapTiler access token for MapLibre
+NUXT_PUBLIC_MAP_MAPLIBRE_TOKEN=
+# Mapbox access token for Mapbox
+NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN=
+
# Storage provider (local or s3)
NUXT_STORAGE_PROVIDER=local
NUXT_PROVIDER_LOCAL_PATH=/app/data/storage
diff --git a/docs/zh/configuration/map-providers.md b/docs/zh/configuration/map-providers.md
index e32d1796..cc6cd66d 100644
--- a/docs/zh/configuration/map-providers.md
+++ b/docs/zh/configuration/map-providers.md
@@ -2,17 +2,18 @@
ChronoFrame 支持两种地图提供器,您可以根据需求选择合适的提供器。
-| 提供器 | 支持 | 额外配置 | 特性 |
-| --------------------- | :--: | --------------- | ------------------------ |
-| [MapLibre](#maplibre) | ✅ | 无 | 免费开源,支持自定义样式 |
-| [Mapbox](#mapbox) | ✅ | MapBox 访问令牌 | 免费用量,更好的渲染器 |
+| 提供器 | 支持 | 额外配置 | 特性 |
+| --------------------- | :--: | ----------------- | ------------------------ |
+| [MapLibre](#maplibre) | ✅ | MapTiler 访问令牌 | 免费开源,支持自定义样式 |
+| [Mapbox](#mapbox) | ✅ | MapBox 访问令牌 | 免费用量,更好的渲染器 |
## MapLibre
-将地图提供器配置为 MapLibre 即可,无需其他配置:
+要使用 MapLibre 作为地图提供器,您需要一个 [MapTiler 访问令牌](https://cloud.maptiler.com/account/keys/)。
```bash
NUXT_PUBLIC_MAP_PROVIDER=maplibre
+NUXT_PUBLIC_MAP_MAPLIBRE_TOKEN=your_maplibre_access_token
```
### 自定义样式
diff --git a/docs/zh/guide/getting-started.md b/docs/zh/guide/getting-started.md
index be7a1228..d2a1a592 100644
--- a/docs/zh/guide/getting-started.md
+++ b/docs/zh/guide/getting-started.md
@@ -55,6 +55,13 @@ NUXT_PUBLIC_APP_SLOGAN=
NUXT_PUBLIC_APP_AUTHOR=
NUXT_PUBLIC_APP_AVATAR_URL=
+# 地图提供器 (maplibre/mapbox)
+NUXT_PUBLIC_MAP_PROVIDER=maplibre
+# 使用 MapLibre 需要 MapTiler 访问令牌
+NUXT_PUBLIC_MAP_MAPLIBRE_TOKEN=
+# 使用 Mapbox 需要 Mapbox 访问令牌
+NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN=
+
# 存储提供者(local 或 s3)
NUXT_STORAGE_PROVIDER=local
NUXT_PROVIDER_LOCAL_PATH=/app/data/storage
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 1884ee49..6e90efc2 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -49,6 +49,7 @@ export default defineNuxtConfig({
style: ''
},
maplibre: {
+ token: '',
style: '',
}
},