Фикс заголовков для локальной карты

This commit is contained in:
2025-12-09 10:59:44 +03:00
parent 25fe93231f
commit 8393734dc3
8 changed files with 34 additions and 7 deletions

View File

@@ -170,7 +170,7 @@ const baseLayers = {
maxZoom: 17, maxZoom: 17,
attribution: '© OpenTopoMap' attribution: '© OpenTopoMap'
}), }),
'Локальная': L.tileLayer('http://127.0.0.1:8090/styles/basic-preview/512/{z}/{x}/{y}.png', { 'Локальная': L.tileLayer('/tiles/styles/basic-preview/512/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
attribution: 'Local Tiles' attribution: 'Local Tiles'
}) })

View File

@@ -52,7 +52,7 @@
attribution: 'Tiles © Esri' attribution: 'Tiles © Esri'
}); });
const street_local = L.tileLayer('http://127.0.0.1:8090/styles/basic-preview/512/{z}/{x}/{y}.png', { const street_local = L.tileLayer('/tiles/styles/basic-preview/512/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
attribution: 'Local Tiles' attribution: 'Local Tiles'
}); });

View File

@@ -86,7 +86,7 @@
attribution: 'Tiles © Esri' attribution: 'Tiles © Esri'
}); });
const street_local = L.tileLayer('http://127.0.0.1:8090/styles/basic-preview/512/{z}/{x}/{y}.png', { const street_local = L.tileLayer('/tiles/styles/basic-preview/512/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
attribution: 'Local Tiles' attribution: 'Local Tiles'
}); });

View File

@@ -75,7 +75,7 @@
attribution: 'Tiles © Esri' attribution: 'Tiles © Esri'
}); });
const street_local = L.tileLayer('http://127.0.0.1:8090/styles/basic-preview/512/{z}/{x}/{y}.png', { const street_local = L.tileLayer('/tiles/styles/basic-preview/512/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
attribution: 'Local Tiles' attribution: 'Local Tiles'
}); });

View File

@@ -7,7 +7,7 @@
<link href="{% static 'leaflet/leaflet.css' %}" rel="stylesheet"> <link href="{% static 'leaflet/leaflet.css' %}" rel="stylesheet">
<link href="{% static 'leaflet-measure/leaflet-measure.css' %}" rel="stylesheet"> <link href="{% static 'leaflet-measure/leaflet-measure.css' %}" rel="stylesheet">
<link href="{% static 'leaflet-tree/L.Control.Layers.Tree.css' %}" rel="stylesheet"> <link href="{% static 'leaflet-tree/L.Control.Layers.Tree.css' %}" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-playback@1.0.2/dist/LeafletPlayback.css" /> <!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-playback@1.0.2/dist/LeafletPlayback.css" /> -->
<style> <style>
body { body {
overflow: hidden; overflow: hidden;
@@ -193,7 +193,7 @@
attribution: 'Tiles &copy; Esri' attribution: 'Tiles &copy; Esri'
}); });
const street_local = L.tileLayer('http://127.0.0.1:8090/styles/basic-preview/512/{z}/{x}/{y}.png', { const street_local = L.tileLayer('/tiles/styles/basic-preview/512/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
attribution: 'Local Tiles' attribution: 'Local Tiles'
}); });

View File

@@ -56,7 +56,7 @@
const satellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { const satellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles &copy; Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' attribution: 'Tiles &copy; Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
}); });
const street_local = L.tileLayer('http://127.0.0.1:8090/styles/basic-preview/512/{z}/{x}/{y}.png', { const street_local = L.tileLayer('/tiles/styles/basic-preview/512/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
attribution: 'Local Tiles' attribution: 'Local Tiles'
}); });

View File

@@ -81,6 +81,7 @@ services:
- tileserver_config:/config - tileserver_config:/config
environment: environment:
- VERBOSE=true - VERBOSE=true
- CORS_ENABLED=true
volumes: volumes:
pgdata: pgdata:

View File

@@ -27,6 +27,32 @@ server {
add_header Cache-Control "public, max-age=2592000"; add_header Cache-Control "public, max-age=2592000";
} }
# Прокси для tileserver-gl с CORS заголовками
location /tiles/ {
proxy_pass http://tileserver:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# CORS заголовки
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
# Обработка preflight запросов
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
}
# Прокси для всех остальных запросов на Django (асинхронный / uvicorn или gunicorn) # Прокси для всех остальных запросов на Django (асинхронный / uvicorn или gunicorn)
location / { location / {
proxy_pass http://django; proxy_pass http://django;