feat: add center option to map

This commit is contained in:
TheClashFruit 2023-11-28 11:18:21 +01:00
parent 8aa128d0e2
commit bfd6326be6
Signed by: TheClashFruit
GPG key ID: D61666AC77D1C29F
3 changed files with 7 additions and 1 deletions

View file

@ -62,6 +62,11 @@
global $twig;
$twig->addGlobal('pageUri', '/map');
if(isset($_GET['center']))
$twig->addGlobal('center', $_GET['center']);
else
$twig->addGlobal('center', '0;0');
echo $twig->render('map.twig');
});

View file

@ -67,7 +67,7 @@ let map = L.map('map', {
transformation: new L.Transformation(1, 0, 1, 0),
projection: L.Projection.LonLat
}),
}).setView([0, 0], 2);
}).setView([ parseInt(center.split(';')[1]), parseInt(center.split(';')[0])], 2);
let baseMaps = {
"Overworld": mapLayer

View file

@ -3,6 +3,7 @@
<div id="map"></div>
<a id="homeLink" href="/">Go Home</a>
<script>const center = "{{ center }}";</script>
<script src="js/map.js"></script>
{% include 'includes/foot.twig' %}