diff --git a/module/geogallery/geogallery.php b/module/geogallery/geogallery.php
index d917e0fc..6cb5f444 100644
--- a/module/geogallery/geogallery.php
+++ b/module/geogallery/geogallery.php
@@ -43,6 +43,8 @@ class geogallery extends common
public static $config = [];
+ public static $galleriesCenter = [];
+
public static $actions = [
'config' => self::GROUP_EDITOR,
'delete' => self::GROUP_EDITOR,
@@ -56,109 +58,6 @@ class geogallery extends common
'index' => self::GROUP_VISITOR
];
- public static $sort = [
- self::SORT_ASC => 'Alphabétique ',
- self::SORT_DSC => 'Alphabétique inverse',
- self::SORT_HAND => 'Manuel'
- ];
-
- public static $galleryThemeFlexAlign = [
- 'flex-start' => 'À gauche',
- 'center' => 'Au centre',
- 'flex-end' => 'À droite',
- 'space-around' => 'Distribué avec marges',
- 'space-between' => 'Distribué sans marge',
- ];
-
- public static $galleryThemeAlign = [
- 'left' => 'À gauche',
- 'center' => 'Au centre',
- 'right' => 'À droite'
- ];
-
- public static $galleryThemeSizeWidth = [
- '9em' => 'Très petite',
- '12em' => 'Petite',
- '15em' => 'Moyenne',
- '18em' => 'Grande',
- '21em' => 'Très grande',
- '100%' => 'Proportionnelle'
- ];
-
- public static $galleryThemeSizeHeight = [
- '9em' => 'Très petite',
- '12em' => 'Petite',
- '15em' => 'Moyenne',
- '18em' => 'Grande',
- '21em' => 'Très grande'
- ];
-
- public static $galleryThemeLegendHeight = [
- '.125em' => 'Très petite',
- '.25em' => 'Petite',
- '.375em' => 'Moyenne',
- '.5em' => 'Grande',
- '.625em' => 'Très grande'
- ];
-
- public static $galleryThemeBorder = [
- '0em' => 'Aucune',
- '.1em' => 'Très fine',
- '.3em' => 'Fine',
- '.5em' => 'Moyenne',
- '.7em' => 'Epaisse',
- '.9em' => 'Très épaisse'
- ];
-
- public static $galleryThemeOpacity = [
- '1' => 'Aucun ',
- '.9' => 'Très Discrète',
- '.8' => 'Discrète',
- '.7' => 'Moyenne',
- '.6' => 'Forte',
- '.5' => 'Très forte'
- ];
-
- public static $galleryThemeMargin = [
- '0em' => 'Aucune',
- '.1em' => 'Très petite',
- '.3em' => 'Petite',
- '.5em' => 'Moyenne',
- '.7em' => 'Grande',
- '.9em' => 'Très grande'
- ];
-
- public static $galleryThemeRadius = [
- '0em' => 'Aucun',
- '.3em' => 'Très léger',
- '.6em' => 'Léger',
- '.9em' => 'Moyen',
- '1.2em' => 'Important',
- '1.5em' => 'Très important'
- ];
-
- public static $galleryThemeShadows = [
- '0px' => 'Aucune',
- '1px 1px 5px' => 'Très légère',
- '1px 1px 10px' => 'Légère',
- '1px 1px 15px' => 'Moyenne',
- '1px 1px 25px' => 'Importante',
- '1px 1px 50px' => 'Très importante'
- ];
-
- public static $galleryOptionBackPosition = [
- 'none' => 'Masqué',
- 'top' => 'Au-dessus',
- 'both' => 'Au-dessus et en dessous',
- 'bottom' => 'En dessous',
- ];
- public static $galleryOptionBackAlign = [
- 'left' => 'A gauche',
- 'center' => 'Au centre',
- 'right' => 'A droite',
- ];
-
- public static $formOptionSelect = '';
/**
* Mise à jour du module
@@ -353,7 +252,7 @@ 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 . ']', helper::FILTER_FLOAT),
+ 'long' => $this->getInput('gpslong[' . $file . ']', helper::FILTER_FLOAT),
'lat' => $this->getInput('gpslat[' . $file . ']', helper::FILTER_FLOAT)
];
}
@@ -503,26 +402,60 @@ 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'])) {
// Coordonnées
self::$galleries[] = [
'lat' => $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']),
'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef']),
- 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename())
+ 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()),
+ 'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $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())
+ '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()),
+ 'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())])
];
}
-
}
}
}
}
+ // Calcul du point central
+
+ // Calculer le centre géographique
+ $totalLat = 0;
+ $totalLong = 0;
+ $count = count(self::$galleries);
+
+ foreach (self::$galleries as $coordinate) {
+ $totalLat += $coordinate["lat"];
+ $totalLong += $coordinate["long"];
+ }
+
+ $centerLat = $totalLat / $count;
+ $centerLong = $totalLong / $count;
+
+ // Calculer la distance maximale au centre pour déterminer le niveau de zoom
+ $maxDistance = 0;
+ foreach (self::$galleries as $coordinate) {
+ $distance = $this->haversineGreatCircleDistance($centerLat, $centerLong, $coordinate["lat"], $coordinate["long"]);
+ if ($distance > $maxDistance) {
+ $maxDistance = $distance;
+ }
+ }
+
+ $zoomLevel = $this->getZoomLevel($maxDistance);
+
+ self::$galleriesCenter = array(
+ 'lat' => $centerLat,
+ 'long' => $centerLong,
+ 'zoom' => $zoomLevel
+ );
+
// Affichage du template
if (self::$galleries) {
// Valeurs en sortie
@@ -603,6 +536,37 @@ class geogallery extends common
return floatval($parts[0]) / floatval($parts[1]);
}
+ // Fonction pour calculer la distance entre deux points géographiques
+ private function haversineGreatCircleDistance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371)
+ {
+ $latFrom = deg2rad($latitudeFrom);
+ $lonFrom = deg2rad($longitudeFrom);
+ $latTo = deg2rad($latitudeTo);
+ $lonTo = deg2rad($longitudeTo);
+
+ $latDelta = $latTo - $latFrom;
+ $lonDelta = $lonTo - $lonFrom;
+
+ $angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) +
+ cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)));
+ return $angle * $earthRadius;
+ }
+
+ // Déterminer le niveau de zoom
+// Cette fonction est une approximation pour le calcul du zoom
+ private function getZoomLevel($maxDistance)
+ {
+ $maxZoom = 21; // Le zoom maximal pour Leaflet
+ $earthCircumference = 40075; // La circonférence de la Terre en km
+
+ for ($zoom = $maxZoom; $zoom >= 0; $zoom--) {
+ if ($maxDistance < ($earthCircumference / pow(2, $zoom))) {
+ return $zoom;
+ }
+ }
+ return 0;
+ }
+
}
class geogalleriesHelper extends helper
diff --git a/module/geogallery/view/index/index.js.php b/module/geogallery/view/index/index.js.php
index 49ef6fba..d249f119 100644
--- a/module/geogallery/view/index/index.js.php
+++ b/module/geogallery/view/index/index.js.php
@@ -12,14 +12,20 @@
* @link http://zwiicms.fr/
*/
+
+// Centrage de la carte et niveau de zoom
+const jsonOptions = '';
+const objOptions = JSON.parse(jsonOptions);
+
// Initialisation de la carte
- var map = L.map('map').setView([51.505, -0.09], 2);
+ var map = L.map('map').setView([objOptions.lat, objOptions.long], objOptions.zoom - 1);
// Ajouter une couche de tuiles OpenStreetMap
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
+
// Les données PHP converties en JSON pour JavaScript
const json = '';
const obj = JSON.parse(json);
@@ -27,6 +33,7 @@
// Ajouter les marqueurs à la carte
obj.forEach(function(location) {
- var marker = L.marker([location.lat, location.long]).addTo(map);
- marker.bindPopup('
Latitude: ' + location.lat + '
Longitude: ' + location.long);
+ var marker = L.marker([location.lat, location.long], {title: location.label});
+ marker.addTo(map);
+ marker.bindPopup('');
});
\ No newline at end of file