/** Базовые тайловые слои Leaflet для портала (CARTO + fallback OSM). */ (function (global) { var OSM = { url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', options: { attribution: '© OpenStreetMap', 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: '© OpenStreetMap contributors © 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));