Difference between revisions of "MediaWiki:Common.js"
From Medivia Online Wiki
| Line 18: | Line 18: | ||
zoomSnap: 1, | zoomSnap: 1, | ||
minZoom: 0, | minZoom: 0, | ||
maxZoom: | maxZoom: 10 // adjust if your tileset supports fewer zoom levels | ||
}); | }); | ||
| Line 24: | Line 24: | ||
map.setView([x, y], zoom); | map.setView([x, y], zoom); | ||
L.tileLayer('https://tafonath.github.io/medivia-mapper/ | L.tileLayer('https://tafonath.github.io/medivia-mapper/map/{z}/{x}/{y}.png', { | ||
tileSize: 256, | tileSize: 256, | ||
noWrap: true, | noWrap: true, | ||
bounds: bounds, | bounds: bounds, | ||
maxZoom: | maxZoom: 10, | ||
minZoom: 0, | minZoom: 0, | ||
attribution: '© Tafonath' | attribution: '© Tafonath', | ||
errorTileUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' // transparent fallback | |||
}).addTo(map); | }).addTo(map); | ||
}); | }); | ||
}); | }); | ||
}); | }); | ||
Revision as of 11:05, 5 July 2025
$(document).ready(function () {
const maps = document.querySelectorAll('.medivia-map');
if (!maps.length) return;
// Load Leaflet CSS
mw.loader.load('https://unpkg.com/[email protected]/dist/leaflet.css', 'text/css');
// Load Leaflet JS
$.getScript('https://unpkg.com/[email protected]/dist/leaflet.js', function () {
maps.forEach(function (el) {
const x = parseInt(el.dataset.x || 2048, 10);
const y = parseInt(el.dataset.y || -2047, 10);
const z = parseInt(el.dataset.z || 7, 10);
const zoom = parseInt(el.dataset.zoom || 2, 10);
const map = L.map(el, {
crs: L.CRS.Simple,
zoomSnap: 1,
minZoom: 0,
maxZoom: 10 // adjust if your tileset supports fewer zoom levels
});
const bounds = [[0, 0], [4096, 4096]];
map.setView([x, y], zoom);
L.tileLayer('https://tafonath.github.io/medivia-mapper/map/{z}/{x}/{y}.png', {
tileSize: 256,
noWrap: true,
bounds: bounds,
maxZoom: 10,
minZoom: 0,
attribution: '© Tafonath',
errorTileUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' // transparent fallback
}).addTo(map);
});
});
});