添加瓦片代理

This commit is contained in:
龙澳
2026-03-31 14:41:17 +08:00
parent f26c930099
commit 4eca349d12
6 changed files with 72 additions and 2 deletions

3
.gitignore vendored
View File

@@ -5,6 +5,9 @@
node_modules/
.claude/
# MapProxy tile cache
tiles/cache/
# TODO: where does this rule come from?
docs/_book

View File

@@ -268,7 +268,7 @@ function initMap() {
attributionControl: false
})
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
maxZoom: 18,
subdomains: 'abcd'
}).addTo(map)

View File

@@ -28,7 +28,13 @@ export default defineConfig({
}
],
server: {
port: 5173
port: 5173,
proxy: {
'/tiles': {
target: 'http://localhost:8080',
changeOrigin: true
}
}
},
build: {
outDir: resolve(__dirname, '../dist')

14
tiles/docker-compose.yml Normal file
View File

@@ -0,0 +1,14 @@
version: '3.8'
services:
mapproxy:
image: kartoza/mapproxy:latest
ports:
- "8080:8080"
volumes:
- ./mapproxy/mapproxy.yaml:/srv/mapproxy/mapproxy.yaml
- ./mapproxy/seed.yaml:/srv/mapproxy/seed.yaml
- ./cache:/srv/mapproxy/cache_data
environment:
- MAPPROXY_PROCESSES=4
restart: unless-stopped

View File

@@ -0,0 +1,34 @@
services:
tms:
grids: [GLOBAL_WEBMERCATOR]
origin: nw
restful: true
layers:
- name: stamen_watercolor
title: Stamen Watercolor (Cached)
sources: [stamen_watercolor_cache]
caches:
stamen_watercolor_cache:
grids: [GLOBAL_WEBMERCATOR]
sources: [stamen_watercolor_source]
cache:
type: file
directory: /srv/mapproxy/cache_data/stamen_watercolor
sources:
stamen_watercolor_source:
type: tile
url: https://tiles.stadiamaps.com/tiles/stamen_watercolor/%(z)s/%(x)s/%(y)s.jpg
grid: GLOBAL_WEBMERCATOR
grids:
GLOBAL_WEBMERCATOR:
srs: EPSG:3857
origin: nw
globals:
cache:
base_dir: /srv/mapproxy/cache_data
lock_dir: /srv/mapproxy/cache_data/.locks

13
tiles/mapproxy/seed.yaml Normal file
View File

@@ -0,0 +1,13 @@
seeds:
stamen_watercolor_seed:
caches: [stamen_watercolor_cache]
grids: [GLOBAL_WEBMERCATOR]
coverages: [china_coverage]
levels:
from: 1
to: 10
coverages:
china_coverage:
bbox: [73.0, 18.0, 135.0, 54.0]
srs: EPSG:4326