SabradouMap/index.php

74 lines
2.8 KiB
PHP
Raw Normal View History

2023-07-11 18:03:40 +02:00
<?php include("core.php"); ?>
2023-07-13 18:31:31 +02:00
2023-07-10 19:36:11 +02:00
<!DOCTYPE html>
<html>
2023-07-11 18:03:40 +02:00
2023-07-10 19:36:11 +02:00
<head>
2023-07-13 18:31:31 +02:00
<title>Carte Sabradou</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css" />
2023-07-11 18:03:40 +02:00
<link rel="stylesheet" href="style.css" />
2023-07-10 19:36:11 +02:00
</head>
2023-07-11 18:03:40 +02:00
2023-07-10 19:36:11 +02:00
<body>
2023-07-11 18:28:08 +02:00
<div class="header">
2023-07-13 18:31:31 +02:00
<h1>GÉOLOCALISATION DES BROCANTES RÉFÉRENCÉES</h1>
<h2>SUR LE SITE <a href="https://www.sabradou.com/" target="_blank">SABRADOU.COM</a></h2>
<form class="form" action="index.php" method="GET">
<label for="calendrier-list">Brocantes du :</label>
2023-07-11 18:03:40 +02:00
<select name="calendrier" id="calendrier-list">
<?php $calendrier = getCalendrier(); ?>
<?php foreach ($calendrier as $item): ?>
<option value="<?php echo $item['url']; ?>"><?php echo $item['node']; ?></option>
<?php endforeach; ?>
</select>
2023-07-11 18:28:08 +02:00
<input type="submit" value="Localiser sur une carte">
2023-07-11 18:03:40 +02:00
</form>
</div>
2023-07-13 18:31:31 +02:00
<div class="container">
<div class="left-column">
<ul class="cities">
<?php $citiesList = getCities('https://www.sabradou.com/index.php'); ?>
<?php if (isset($citiesList)): ?>
<?php foreach ($citiesList as $city): ?>
<li>
<?php echo $city['name']; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
<div class="right-column">
<?php
if (isset($_GET['calendrier'])) {
$jour = $_GET['calendrier'];
$citiesList = getCities($jour);
$citiesGeoCode = geocode($citiesList);
?>
<div id="map"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"></script>
<script>
// Tableau des villes et des coordonnées
var cities = <?php echo json_encode($citiesGeoCode); ?>;
// Créer la carte
var map = L.map('map').setView([50.5095, 2.6683], 9);
// Ajouter une couche de tuiles OpenStreetMap à la carte
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Carte OpenStreetMap'
}).addTo(map);
// Placer des marqueurs pour chaque ville sur la carte
cities.forEach(function (city) {
var marker = L.marker([city.lat, city.lon]).addTo(map);
marker.bindPopup('<a href="' + city.href + '" target="_blank">' + city.name + '</a>');
});
</script>
<?php } ?>
</div>
</div>
2023-07-10 19:36:11 +02:00
</body>
2023-07-11 18:03:40 +02:00
2023-07-11 14:08:23 +02:00
</html>