<?php
/* @license GNU General Public License, version 3
 * création @Lionel Croquefer 2019
 * Version du 13 avril 2026
 */
session_start();
switch ($_SESSION['langAdmin']) {
    case 'en':
        $textAltitude = "'altitude = '";
        $textAlt = "'indefinite or 0'";
        break;
    case 'es':
        $textAltitude = "'altitud = '";
        $textAlt = "'indefinida o 0'";
        break;
    case 'fr':
        $textAltitude = "'altitude = '";
        $textAlt = "'indéterminée ou 0'";
        break;
	}
$lat = $_GET['lat'];
$lon = $_GET['lon'];
$altitude = $_GET['alt'];
if ($altitude > 0) { $alt = $altitude; }
else {
$alt = $textAlt;
}
$zoom = $_GET['zoom'];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Mapop</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="../../../core/vendor/geolocation/leaflet/leaflet.css">
<link rel="stylesheet" href="../../../core/vendor/geolocation/leaflet/Control.FullScreen.css">
<style>
html, body{
width: 100vw;
height: 100%;
}
body {
padding: 0;
margin: 0;
}
#mapid {
width: 100%;
height: 100vh;
}
</style>
<script src="../../../core/vendor/geolocation/leaflet/leaflet.js"></script>
<script src="../../../core/vendor/geolocation/leaflet/Control.FullScreen.js"></script>
</head>

<body>
<div id="mapid"> </div>
<script>
const mymap = L.map('mapid',{
	fullscreenControl: true,
	fullscreenControlOptions: {
	position: 'topleft'
}}).setView([<?=$lat?>, <?=$lon?>], <?=$zoom?>);

const baselayers = {
"OpenHikingMap": L.tileLayer("https://tile.openmaps.fr/opentopomap/{z}/{x}/{y}.png", {
		maxZoom: 19,
		maxNativeZoom: 18,
		attribution: '&copy; <a href="//openmaps.fr/" target="_blank">OpenHikingMap</a> | SRTM (CC-BY-SA)'
	}),
"OpenStreetMap": L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
		maxZoom: 19,
		attribution: '&copy; <a href="//www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>'
	}),
"Satellite" : L.tileLayer("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", {
		maxZoom: 19,
		maxNativeZoom: 18,
		attribution: '&copy; <a href="//www.esri.com/fr-fr/" target="_blank">Esri</a> ArcGIS'
	})
};

let marker = L.marker([<?=$lat?>, <?=$lon?>]).addTo(mymap)
    .bindPopup(<?=$textAltitude?> +' '+ <?=$alt?> +' m')
    .openPopup();

let layerControl = L.control.layers(baselayers).addTo(mymap);
baselayers.Satellite.addTo(mymap);

	// detect fullscreen toggling
	mymap.on('enterFullscreen', function(){
		if(window.console) window.console.log('enterFullscreen');
	});
	mymap.on('exitFullscreen', function(){
		if(window.console) window.console.log('exitFullscreen');
	});
</script>
</body>
</html>
