fix: map fixes

This commit is contained in:
TheClashFruit 2023-11-17 21:07:31 +01:00
parent ae6f145720
commit 9d7d7aab47
Signed by: TheClashFruit
GPG key ID: 09BB24C34C2F3204

View file

@ -6,6 +6,8 @@
<script> <script>
L.TileLayer.CRSSLayer = L.TileLayer.extend({ L.TileLayer.CRSSLayer = L.TileLayer.extend({
getTileUrl: function(coordinate) { getTileUrl: function(coordinate) {
console.log(coordinate);
const tileX = coordinate.x; const tileX = coordinate.x;
const tileY = coordinate.y; const tileY = coordinate.y;
@ -23,13 +25,20 @@
return new L.TileLayer.CRSSLayer(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', { let mapLayer = L.tileLayer.crssLayer('https://cdn.theclashfruit.me/crss/map_new/{xd}/{yd}/tile.{x}.{y}.png', {
attribution: '&copy; <a href="https://crss.blurryface.xyz/">CRSS</a> players', attribution: '&copy; <a href="https://crss.blurryface.xyz/">CRSS</a> players',
tileSize: 256,
noWrap: true, noWrap: true,
maxNativeZoom: 0, maxNativeZoom: 0,
minNativeZoom: 0, minNativeZoom: 0,
origin: [0, 0],
minZoom: -2,
maxZoom: -2 + 12,
zoomOffset: -12
}); });
const worldMinX = -3 * 512; const worldMinX = -3 * 512;
@ -41,14 +50,9 @@
const worldMaxZoomFactor = Math.pow(2, 0); 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([ let ropMarkers = L.layerGroup([
infoCentre L.marker([-75.5, 49.5])
.bindPopup('Info Centre')
]); ]);
let rorMarkers = L.layerGroup([ let rorMarkers = L.layerGroup([
@ -56,13 +60,22 @@
]); ]);
let miscMarkers = L.layerGroup([ let miscMarkers = L.layerGroup([
zeroZero L.marker([0.5, 0.5])
.bindPopup('0; 0'),
L.marker([1302.5, -661.5])
.bindPopup('The Dropper'),
]); ]);
console.log(L.CRS.Simple.infinite)
let map = L.map('map', { let map = L.map('map', {
layers: [mapLayer, ropMarkers], layers: [mapLayer, miscMarkers, ropMarkers, rorMarkers],
crs: L.CRS.Simple, preferCanvas: true,
}).setView([0.5, 0.5], 2); crs: L.Util.extend(L.CRS.Simple, {
transformation: new L.Transformation(1, 0, 1, 0),
projection: L.Projection.LonLat
}),
}).setView([0, 0], 2);
let baseMaps = { let baseMaps = {
"Overworld": mapLayer "Overworld": mapLayer
@ -80,11 +93,13 @@
position: 'bottomright', position: 'bottomright',
separator: '; ', separator: '; ',
lngFormatter: (x) => { lngFormatter: (x) => {
return x.toFixed(3) return Math.floor(x)
}, },
latFormatter: (y) => { latFormatter: (y) => {
return y.toFixed(3) return Math.floor(y)
} },
wrapLng: false,
lngFirst: true
}).addTo(map); }).addTo(map);
</script> </script>