Website/template/map.twig

106 lines
2.4 KiB
Twig
Raw Normal View History

2023-09-15 15:53:33 +00:00
{% include 'includes/head.twig' with {'pageTitle': 'Map'} %}
2023-09-15 15:48:05 +00:00
2023-09-18 16:10:55 +00:00
<div id="map"></div>
<a id="homeLink" href="/">Go Home</a>
2023-09-15 15:48:05 +00:00
2023-09-18 16:10:55 +00:00
<script>
2023-11-17 17:30:57 +00:00
L.TileLayer.CRSSLayer = L.TileLayer.extend({
getTileUrl: function(coordinate) {
2023-11-17 20:07:31 +00:00
console.log(coordinate);
2023-11-17 17:30:57 +00:00
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);
}
2023-11-17 20:07:31 +00:00
let mapLayer = L.tileLayer.crssLayer('https://cdn.theclashfruit.me/crss/map_new/{xd}/{yd}/tile.{x}.{y}.png', {
2023-09-18 16:37:58 +00:00
attribution: '&copy; <a href="https://crss.blurryface.xyz/">CRSS</a> players',
2023-11-17 20:07:31 +00:00
tileSize: 256,
2023-09-18 17:42:59 +00:00
noWrap: true,
2023-11-17 20:07:31 +00:00
2023-11-17 17:30:57 +00:00
maxNativeZoom: 0,
minNativeZoom: 0,
2023-11-17 20:07:31 +00:00
minZoom: -2,
maxZoom: -2 + 12,
zoomOffset: -12
2023-09-18 16:37:58 +00:00
});
2023-11-17 17:30:57 +00:00
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);
2023-09-18 16:37:58 +00:00
2023-11-17 18:38:27 +00:00
let ropMarkers = L.layerGroup([
2023-11-17 20:07:31 +00:00
L.marker([-75.5, 49.5])
.bindPopup('Info Centre')
2023-11-17 18:38:27 +00:00
]);
let rorMarkers = L.layerGroup([
]);
let miscMarkers = L.layerGroup([
2023-11-17 20:07:31 +00:00
L.marker([0.5, 0.5])
.bindPopup('0; 0'),
L.marker([1302.5, -661.5])
.bindPopup('The Dropper'),
2023-09-18 16:37:58 +00:00
]);
2023-11-17 20:07:31 +00:00
console.log(L.CRS.Simple.infinite)
2023-09-18 16:37:58 +00:00
let map = L.map('map', {
2023-11-17 20:07:31 +00:00
layers: [mapLayer, miscMarkers, ropMarkers, rorMarkers],
preferCanvas: true,
crs: L.Util.extend(L.CRS.Simple, {
transformation: new L.Transformation(1, 0, 1, 0),
projection: L.Projection.LonLat
}),
}).setView([0, 0], 2);
2023-09-18 16:10:55 +00:00
2023-09-18 16:37:58 +00:00
let baseMaps = {
2023-11-17 17:30:57 +00:00
"Overworld": mapLayer
2023-09-18 16:37:58 +00:00
};
2023-09-18 16:10:55 +00:00
2023-09-18 16:37:58 +00:00
let overlayMaps = {
2023-11-17 18:38:27 +00:00
"Miscellaneous Markers": miscMarkers,
"Markers in RoP": ropMarkers,
"Markers in DRoR": rorMarkers,
2023-09-18 16:37:58 +00:00
};
2023-09-18 16:10:55 +00:00
2023-09-18 16:37:58 +00:00
let layerControl = L.control.layers(baseMaps, overlayMaps).addTo(map);
2023-11-17 18:21:47 +00:00
L.control.mousePosition({
position: 'bottomright',
separator: '; ',
lngFormatter: (x) => {
2023-11-17 20:07:31 +00:00
return Math.floor(x)
},
latFormatter: (y) => {
2023-11-17 20:07:31 +00:00
return Math.floor(y)
},
wrapLng: false,
lngFirst: true
2023-11-17 18:21:47 +00:00
}).addTo(map);
2023-09-18 16:10:55 +00:00
</script>
2023-09-15 15:48:05 +00:00
{% include 'includes/foot.twig' %}