Files
ACORE/static/assets/js/map-tiles.js
T
lokses ae54d93442 core: секции портала, контроль доступа и вью страниц
Section-based portal access, matrix прав по группам, аккаунтинг-портал,
управление группами пользователей, справочники, дашборд и общий каркас
навигации/стилей.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-09 18:03:20 +03:00

56 lines
1.6 KiB
JavaScript

/** Базовые тайловые слои Leaflet для портала (CARTO + fallback OSM). */
(function (global) {
var OSM = {
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: {
attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a>',
maxZoom: 19,
},
};
function cartoApiKey() {
return (global.ACORE_MAP_CONFIG && global.ACORE_MAP_CONFIG.cartoApiKey) || '';
}
function cartoLightSource() {
var key = cartoApiKey();
if (!key) return null;
return {
url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png?key=' + encodeURIComponent(key),
options: {
attribution: '&copy; OpenStreetMap contributors &copy; CARTO',
maxZoom: 20,
subdomains: 'abcd',
},
};
}
function tileSources() {
var carto = cartoLightSource();
return carto ? [carto, OSM] : [OSM];
}
global.acoreMapTileSources = tileSources;
global.acoreAddMapBaseLayer = function (map) {
var sources = tileSources();
var idx = 0;
var layer = null;
function mount() {
if (idx >= sources.length) return;
var src = sources[idx];
layer = global.L.tileLayer(src.url, src.options).addTo(map);
layer.on('tileerror', function () {
if (idx + 1 >= sources.length) return;
map.removeLayer(layer);
idx += 1;
mount();
});
}
mount();
return layer;
};
}(window));