Website/template/map.twig

91 lines
2.1 KiB
Twig

{% include 'includes/head.twig' with {'pageTitle': 'Map'} %}
<div id="map"></div>
<a id="homeLink" href="/">Go Home</a>
<script>
L.TileLayer.CRSSLayer = L.TileLayer.extend({
getTileUrl: function(coordinate) {
const tileX = coordinate.x;
const tileY = coordinate.y;
const url = ('https://cdn.theclashfruit.me/crss/map_new/{xd}/{yd}/tile.{x}.{y}.png')
.replace('{yd}', Math.floor(tileY / 10))
.replace('{xd}', Math.floor(tileX / 10))
.replace('{y}', tileY)
.replace('{x}', tileX);
return url;
}
});
L.tileLayer.crssLayer = function(templateUrl, options) {
return new L.TileLayer.CRSSLayer(templateUrl, options);
}
let mapLayer = L.tileLayer.crssLayer('https://cdn.theclashfruit.me/crss/map_new/{x}/{y}/tile.{x}.{y}.png', {
attribution: '&copy; <a href="https://crss.blurryface.xyz/">CRSS</a> players',
noWrap: true,
maxNativeZoom: 0,
minNativeZoom: 0,
origin: [0, 0],
});
const worldMinX = -3 * 512;
const worldMinY = -7 * 512;
const worldWidth = (8 + 1 - (-3)) * 512;
const worldHeight = (4 + 1 - (-7)) * 512;
const worldTileSize = 256;
const worldMaxZoomFactor = Math.pow(2, 0);
let zeroZero = L.marker([0.5, 0.5])
.bindPopup('0; 0');
let infoCentre = L.marker([75.5, 49.5])
.bindPopup('Info Centre');
let ropMarkers = L.layerGroup([
infoCentre
]);
let rorMarkers = L.layerGroup([
]);
let miscMarkers = L.layerGroup([
zeroZero
]);
let map = L.map('map', {
layers: [mapLayer, ropMarkers],
crs: L.CRS.Simple,
}).setView([0.5, 0.5], 2);
let baseMaps = {
"Overworld": mapLayer
};
let overlayMaps = {
"Miscellaneous Markers": miscMarkers,
"Markers in RoP": ropMarkers,
"Markers in DRoR": rorMarkers,
};
let layerControl = L.control.layers(baseMaps, overlayMaps).addTo(map);
L.control.mousePosition({
position: 'bottomright',
separator: '; ',
lngFormatter: (x) => {
return x.toFixed(3)
},
latFormatter: (y) => {
return y.toFixed(3)
}
}).addTo(map);
</script>
{% include 'includes/foot.twig' %}