- on ne stocke pas les coordonnées geo

- la carte ne s'affiche pas.
This commit is contained in:
Fred Tempez 2024-04-18 13:43:21 +02:00
parent fa0022aa65
commit 2d26d2b872
3 changed files with 72 additions and 25 deletions

View File

@ -369,6 +369,9 @@ class geogallery extends common
foreach ($p as $positionId => $item) {
$galleries[$positionId] = $g[$positionId];
}
// Traitement de l'affichage
if ($galleries) {
foreach ($galleries as $galleryId => $gallery) {
@ -565,8 +568,8 @@ class geogallery extends common
// Données géographiques
foreach ((array) $this->getInput('legend', null) as $file => $data) {
$geo[$file] = [
'long' => $this->getInput('gpslong['. $file .']'),
'lat' => $this->getInput('gpslat['. $file .']')
'long' => $this->getInput('gpslong[' . $file . ']'),
'lat' => $this->getInput('gpslat[' . $file . ']')
];
}
// Sauvegarder
@ -585,10 +588,9 @@ class geogallery extends common
'position' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'position']),
'fullScreen' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'fullScreen']),
'showPageContent' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'showPageContent'])
],
'legend' => $legends,
'geo' => $geo,
//'geo' => $geo,
'positions' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'positions'])
]
]);
@ -624,8 +626,8 @@ class geogallery extends common
}
// Obtenir les métadonnées EXIF de l'image
$exif = exif_read_data($fileInfos->getPath() . '/' . $fileInfos->getFilename());
$latitude = null;
$longitude = null;
$latitude = 'Donnée absente';
$longitude = 'Donnée absente';
// Vérifier si les données EXIF contiennent des informations de géolocalisation
if (!empty($exif['GPSLatitude']) && !empty($exif['GPSLongitude'])) {
// Coordonnées de latitude
@ -646,10 +648,12 @@ class geogallery extends common
'value' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'legend', str_replace('.', '', $fileInfos->getFilename())])
]),
template::text('gpslong[' . $fileInfos->getFilename() . ']', [
'value' => $longitude
'value' => $longitude,
'readonly' => true,
]) . '<br />' .
template::text('gpslat[' . $fileInfos->getFilename() . ']', [
'value' => $latitude
'value' => $latitude,
'readonly' => true,
]),
'<a href="' . str_replace('source', 'thumb', $directory) . '/' . self::THUMBS_SEPARATOR . $fileInfos->getFilename() . '" rel="data-lity" data-lity=""><img src="' . str_replace('source', 'thumb', $directory) . '/' . $fileInfos->getFilename() . '"></a>',
];
@ -767,6 +771,16 @@ class geogallery extends common
? str_replace('source', 'thumb', $directory) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename())
: str_replace('source', 'thumb', $directory) . '/' . strtolower($fileInfos->getFilename());
$exif = exif_read_data($fileInfos->getPath() . '/' . $fileInfos->getFilename());
// Vérifier si les données EXIF contiennent des informations de géolocalisation
if (!empty($exif['GPSLatitude']) && !empty($exif['GPSLongitude'])) {
// Coordonnées
self::$pictures[$directory . '/' . $fileInfos->getFilename()] = [
'lat' => $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']),
'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef'])
];
}
}
}
// Tri des images par ordre alphabétique
@ -800,6 +814,9 @@ class geogallery extends common
? $this->getData(['module', $this->getUrl(0), 'theme', 'style'])
: '',
'showPageContent' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'config', 'showPageContent']),
'vendor' => [
'leaflet'
],
]);
}
// Pas d'image dans la galerie

View File

@ -23,9 +23,49 @@ var b = new SimpleLightbox('.galleryGalleryPicture', {
closeText: "&times;"
});
$( document ).ready(function() {
$(document).ready(function () {
// Démarre en mode plein écran
if ( $("#pictureContainer").hasClass("fullScreen") ) {
if ($("#pictureContainer").hasClass("fullScreen")) {
$('a#homePicture')[0].click();
}
});
// Créer une carte Leaflet centrée sur une position par défaut
var map = L.map('map').setView([0, 0], 2);
// Ajouter une couche de tuiles OpenStreetMap à la carte
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// Récupérer les données JSON des positions des images à partir de la donnée cachée dans le HTML
var jsonDataString = document.getElementById('imageData').value;
var jsonData = JSON.parse(jsonDataString);
// Créer un tableau pour stocker les marqueurs des images
var markers = [];
// Parcourir les données JSON et ajouter des marqueurs pour chaque image
Object.keys(jsonData).forEach(function (imageName) {
var image = jsonData[imageName];
var marker = L.marker([image.lat, image.long]).addTo(map);
markers.push(marker);
});
// Calculer la moyenne des positions des images
var sumLat = 0;
var sumLong = 0;
Object.values(jsonData).forEach(function (image) {
sumLat += image.lat;
sumLong += image.long;
});
var avgLat = sumLat / Object.keys(jsonData).length;
var avgLong = sumLong / Object.keys(jsonData).length;
// Centrer la carte sur la moyenne des positions des images
map.setView([avgLat, avgLong]);
});

View File

@ -7,21 +7,11 @@
</div>
</div>
<div id="pictureContainer" class="row galleryRow <?php echo ($module::$config['fullScreen']);?> ">
<?php foreach($module::$pictures as $picture => $legend): ?>
<div class="colPicture">
<a
href="<?php echo helper::baseUrl(false) . $picture; ?>"
<?php if ( strpos($picture, $module::$config['homePicture']) > 1) { echo 'id="homePicture"'; } ?>
class="galleryGalleryPicture"
style="background-image:url('<?php echo helper::baseUrl(false) . $module::$thumbs[$picture]; ?>')"
data-caption="<?php echo $legend; ?>"
>
<?php if($legend): ?>
<div class="galleryGalleryName"><?php echo $legend; ?></div>
<?php endif; ?>
</a>
</div>
<?php foreach($module::$pictures as $picture => $datas): ?>
<?php endforeach; ?>
<div id="map"></div>
<input type="hidden" id="imageData" value="<?php echo htmlspecialchars(json_encode($module::$pictures)); ?>">
</div>
<div class="row <?php echo $module::$config['backAlign'] . ' ' . $module::$config['backPositionBottom'];?>">
<div class="col1">