/*
* Silir 26.9.3 - OpenSID 2607.0.1 Custom Stable P16
* GIS Basemap Compatibility v1.1
*
* Keeps Silir maps aligned with P16 free basemap stack even when an older
* assets/js/peta.js is still served/cached by the browser/PWA.
* No token/licence logic is touched.
*/
(function (window) {
'use strict';
if (!window.L || !L.tileLayer) {
return;
}
function configuredJenisPeta(explicitValue) {
if (explicitValue !== undefined && explicitValue !== null && explicitValue !== '') {
return String(explicitValue);
}
try {
if (typeof setting !== 'undefined' && setting && setting.jenis_peta !== undefined) {
return String(setting.jenis_peta);
}
} catch (e) {
// Ignore and use the P16 free satellite fallback below.
}
return '6';
}
function layerMaxZoom(map, layer, configuredMaxZoom) {
var layerMax = Number(layer && layer._opensidMaxZoom);
var maxZoom = isFinite(layerMax) ? Math.min(layerMax, configuredMaxZoom) : configuredMaxZoom;
if (map && typeof map.setMaxZoom === 'function') {
map.setMaxZoom(maxZoom);
if (typeof map.getZoom === 'function' && map.getZoom() > maxZoom) {
map.setZoom(maxZoom);
}
}
}
window.getBaseLayers = function (peta, access_token, jenis_peta) {
var optionMaxZoom = peta && peta.options ? Number(peta.options.maxZoom) : 22;
var configuredMaxZoom = Math.min(optionMaxZoom || 22, 22);
var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: Math.min(configuredMaxZoom, 19),
attribution: '© OpenStreetMap contributors | OpenSID'
});
osm._opensidMaxZoom = Math.min(configuredMaxZoom, 19);
var osmHot = L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
maxZoom: Math.min(configuredMaxZoom, 19),
attribution: '© OpenStreetMap contributors | HOT | OpenSID'
});
osmHot._opensidMaxZoom = Math.min(configuredMaxZoom, 19);
var eoxAttribution = 'EOX Cloudless cloudless.eox.at (Contains modified Copernicus Sentinel data 2025)';
var sentinelSatellite = L.tileLayer('https://tiles.maps.eox.at/wmts/1.0.0/s2cloudless-2025_3857/default/g/{z}/{y}/{x}.jpg', {
minZoom: 0,
maxNativeZoom: 14,
maxZoom: configuredMaxZoom,
tileSize: 256,
crossOrigin: true,
attribution: eoxAttribution
});
sentinelSatellite._opensidMaxZoom = configuredMaxZoom;
var eoxLabels = L.tileLayer.wms('https://tiles.maps.eox.at/map', {
layers: 'overlay_bright_3857',
format: 'image/png',
transparent: true,
version: '1.1.1',
maxNativeZoom: 18,
maxZoom: configuredMaxZoom,
crossOrigin: true,
attribution: 'Overlay: © OpenStreetMap contributors, Rendering © EOX/MapServer'
});
var sentinelHybrid = L.layerGroup([sentinelSatellite, eoxLabels]);
sentinelHybrid._opensidMaxZoom = configuredMaxZoom;
var esriSatellite = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
minZoom: 0,
maxNativeZoom: 22,
maxZoom: configuredMaxZoom,
tileSize: 256,
crossOrigin: true,
attribution: 'Tiles © Esri — World Imagery'
});
esriSatellite._opensidMaxZoom = configuredMaxZoom;
var esriClarity = L.tileLayer('https://clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
minZoom: 0,
maxNativeZoom: 22,
maxZoom: configuredMaxZoom,
tileSize: 256,
crossOrigin: true,
attribution: 'Tiles © Esri — World Imagery (Clarity)'
});
esriClarity._opensidMaxZoom = configuredMaxZoom;
var baseLayers = {
'OpenStreetMap': osm,
'OpenStreetMap H.O.T.': osmHot,
'Esri Satellite (World Imagery)': esriSatellite,
'Esri Clarity (arsip)': esriClarity,
'Satellite Gratis (Sentinel-2 2025)': sentinelSatellite,
'Satellite + Label (EOX/OSM)': sentinelHybrid
};
var selected = configuredJenisPeta(jenis_peta);
var activeLayer = sentinelSatellite;
switch (selected) {
case '1':
activeLayer = osm;
break;
case '2':
activeLayer = osmHot;
break;
case '7':
activeLayer = sentinelHybrid;
break;
case '8':
activeLayer = esriSatellite;
break;
case '9':
activeLayer = esriClarity;
break;
case '6':
default:
activeLayer = sentinelSatellite;
break;
}
activeLayer.addTo(peta);
layerMaxZoom(peta, activeLayer, configuredMaxZoom);
if (peta && typeof peta.on === 'function') {
peta.on('baselayerchange', function (event) {
layerMaxZoom(peta, event.layer, configuredMaxZoom);
});
}
return baseLayers;
};
})(window);