Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Carte du monde</title>
- <meta charset="utf-8"/>
- <link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css"
- integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
- crossorigin=""/>
- <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"
- integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
- crossorigin=""></script>
- <style>
- img
- {
- width: 200px;
- height: 200px;
- }
- </style>
- </head>
- <body>
- <h1>Carte du monde</h1>
- <section id="main">
- <div id="testMap" style="height: 600px; width: 100%;"></div>
- <div><a href="liste.php">Retour à la liste</a></div>
- </section>
- <?php
- $rep ="./Images/";
- function getGps($exifCoord, $hemi) {
- $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
- $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
- $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
- $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
- return $flip * ($degrees + $minutes / 60 + $seconds / 3600);
- }
- function gps2Num($coordPart) {
- $parts = explode('/', $coordPart);
- if (count($parts) <= 0)
- return 0;
- if (count($parts) == 1)
- return $parts[0];
- return floatval($parts[0]) / floatval($parts[1]);
- }
- /* Test ligne de commande */
- $script = "<script>";
- $script = $script.'var mymap = L.map("testMap").setView([0, 0], 2);';
- $script = $script.'L.tileLayer("https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw", {
- maxZoom: 15,
- attribution: "Map data © <a href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> contributors, " +
- "<a href=\"https://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>, " +
- "Imagery © <a href=\"https://www.mapbox.com/\">Mapbox</a>",
- id: "mapbox.streets"
- }).addTo(mymap);';
- $script = $script.'var popup = L.popup();';
- foreach (glob($rep."*.jpg") as $filename){
- $exif = exif_read_data($filename, 0, true);
- if (array_key_exists("GPS",$exif)){
- $lon = getGps($exif["GPS"]["GPSLongitude"], $exif["GPS"]["GPSLongitudeRef"]);
- $lat = getGps($exif["GPS"]["GPSLatitude"], $exif["GPS"]["GPSLatitudeRef"]);
- $tag = "\"<img src='".$filename."' alt='Image de la position'>\"";
- $script = $script.'L.marker(['.$lat.', '.$lon.']).addTo(mymap).bindPopup('.$tag.').closePopup();';
- }
- }
- $script = $script."</script>";
- echo $script;
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement