diff --git a/module/geogallery/geogallery.php b/module/geogallery/geogallery.php index ac16b61c..d917e0fc 100644 --- a/module/geogallery/geogallery.php +++ b/module/geogallery/geogallery.php @@ -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()) ]; } diff --git a/module/geogallery/view/index/index.js.php b/module/geogallery/view/index/index.js.php index 7676d755..49ef6fba 100644 --- a/module/geogallery/view/index/index.js.php +++ b/module/geogallery/view/index/index.js.php @@ -12,54 +12,21 @@ * @link http://zwiicms.fr/ */ -// Récupérer les données JSON des positions des images -var jsonData = ""; -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: '© OpenStreetMap 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 = ''; + 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 ` -
- ${legendText} -

${legendText}

-
- `; -} - -// 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); - } - } - } -} \ No newline at end of file + + // Ajouter les marqueurs à la carte + obj.forEach(function(location) { + var marker = L.marker([location.lat, location.long]).addTo(map); + marker.bindPopup('Thumbnail
Latitude: ' + location.lat + '
Longitude: ' + location.long); + }); \ No newline at end of file diff --git a/module/geogallery/view/index/index.php b/module/geogallery/view/index/index.php index b3a146fc..1e344f14 100644 --- a/module/geogallery/view/index/index.php +++ b/module/geogallery/view/index/index.php @@ -1,8 +1,4 @@ -
-		
-