Tout marche !
This commit is contained in:
parent
31b31ce99e
commit
95fb2d6fab
@ -353,8 +353,8 @@ class geogallery extends common
|
||||
// Données géographiques
|
||||
foreach ((array) $this->getInput('legend', null) as $file => $data) {
|
||||
$geo[str_replace('.', '', $file)] = [
|
||||
'long' => $this->getInput('gpslong[' . $file . ']'),
|
||||
'lat' => $this->getInput('gpslat[' . $file . ']')
|
||||
'long' => $this->getInput('gpslong[' . $file . ']', helper::FILTER_FLOAT),
|
||||
'lat' => $this->getInput('gpslat[' . $file . ']', helper::FILTER_FLOAT)
|
||||
];
|
||||
}
|
||||
// Sauvegarder
|
||||
@ -493,7 +493,7 @@ class geogallery extends common
|
||||
$iterator = new DirectoryIterator($directory);
|
||||
foreach ($iterator as $fileInfos) {
|
||||
if ($fileInfos->isDot() === false and $fileInfos->isFile() and @getimagesize($fileInfos->getPathname())) {
|
||||
self::$galleries[$directory . '/' . $fileInfos->getFilename()] = $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())]);
|
||||
|
||||
// Créer la miniature si manquante
|
||||
if (!file_exists(str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()))) {
|
||||
$this->makeThumb(
|
||||
@ -504,11 +504,18 @@ class geogallery extends common
|
||||
}
|
||||
$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'])) {
|
||||
if (!empty($exif['GPSLatitude']) || !empty($exif['GPSLongitude'])) {
|
||||
// Coordonnées
|
||||
self::$galleries[$directory . '/' . $fileInfos->getFilename()] = [
|
||||
self::$galleries[] = [
|
||||
'lat' => $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']),
|
||||
'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef'])
|
||||
'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef']),
|
||||
'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename())
|
||||
];
|
||||
} else {
|
||||
self::$galleries[] = [
|
||||
'lat' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'positions', 'directory', str_replace('.', '', $fileInfos->getFilename())]) ,
|
||||
'long' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'positions', 'directory', str_replace('.', '', $fileInfos->getFilename())]),
|
||||
'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename())
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -12,54 +12,21 @@
|
||||
* @link http://zwiicms.fr/
|
||||
*/
|
||||
|
||||
// Récupérer les données JSON des positions des images
|
||||
var jsonData = "<?php echo json_encode($module::$galleries); ?>";
|
||||
jsonData = JSON.parse(jsonData);
|
||||
// Initialisation de la carte
|
||||
var map = L.map('map').setView([51.505, -0.09], 2);
|
||||
|
||||
// Initialize the map
|
||||
var map = L.map('map').setView([51.505, -0.09], 5);
|
||||
// Ajouter une couche de tuiles OpenStreetMap
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
// Add OpenStreetMap tile layer
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
}).addTo(map);
|
||||
// Les données PHP converties en JSON pour JavaScript
|
||||
const json = '<?php echo json_encode($module::$galleries); ?>';
|
||||
const obj = JSON.parse(json);
|
||||
|
||||
// Helper function to create a popup content
|
||||
function createPopupContent(image, legend, directory) {
|
||||
var imageUrl = directory + '/' + image;
|
||||
var legendText = legend[image.replace('.jpg', 'jpg')];
|
||||
return `
|
||||
<div>
|
||||
<img src="${imageUrl}" alt="${legendText}" style="width: 100px; height: auto;" />
|
||||
<p>${legendText}</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
// Loop through each geotag dataset
|
||||
for (var key in jsonData) {
|
||||
if (jsonData.hasOwnProperty(key)) {
|
||||
var gallery = jsonData[key];
|
||||
var directory = gallery.config.directory;
|
||||
var legend = gallery.legend;
|
||||
var positions = gallery.positions;
|
||||
|
||||
// Loop through each image position
|
||||
for (var image in positions) {
|
||||
if (positions.hasOwnProperty(image)) {
|
||||
var position = positions[image];
|
||||
var lat = parseFloat(position.lat);
|
||||
var long = parseFloat(position.long);
|
||||
|
||||
// Create a marker
|
||||
var marker = L.marker([lat, long]).addTo(map);
|
||||
|
||||
// Create popup content
|
||||
var popupContent = createPopupContent(image, legend, directory);
|
||||
|
||||
// Bind the popup to the marker
|
||||
marker.bindPopup(popupContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ajouter les marqueurs à la carte
|
||||
obj.forEach(function(location) {
|
||||
var marker = L.marker([location.lat, location.long]).addTo(map);
|
||||
marker.bindPopup('<img src="' + location.thumb + '" alt="Thumbnail" style="width:100px;height:auto;"><br>Latitude: ' + location.lat + '<br>Longitude: ' + location.long);
|
||||
});
|
@ -1,8 +1,4 @@
|
||||
<?php if ($module::$galleries): ?>
|
||||
<pre>
|
||||
<?php ;
|
||||
var_dump($module::$galleries); ?>
|
||||
</pre>
|
||||
<div id="map"></div>
|
||||
<?php else: ?>
|
||||
<?php echo template::speech('Aucune galerie'); ?>
|
||||
|
Loading…
Reference in New Issue
Block a user