Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Carte du monde</title>
  5. <meta charset="utf-8"/>
  6. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css"
  7. integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
  8. crossorigin=""/>
  9. <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"
  10. integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
  11. crossorigin=""></script>
  12. <style>
  13. img
  14. {
  15. width: 200px;
  16. height: 200px;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <h1>Carte du monde</h1>
  22. <section id="main">
  23. <div id="testMap" style="height: 600px; width: 100%;"></div>
  24. <div><a href="liste.php">Retour à la liste</a></div>
  25. </section>
  26. <?php
  27. $rep ="./Images/";
  28.  
  29. function getGps($exifCoord, $hemi) {
  30. $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
  31. $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
  32. $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
  33. $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
  34. return $flip * ($degrees + $minutes / 60 + $seconds / 3600);
  35. }
  36.  
  37. function gps2Num($coordPart) {
  38. $parts = explode('/', $coordPart);
  39. if (count($parts) <= 0)
  40. return 0;
  41. if (count($parts) == 1)
  42. return $parts[0];
  43. return floatval($parts[0]) / floatval($parts[1]);
  44. }
  45.  
  46. /* Test ligne de commande */
  47.  
  48. $script = "<script>";
  49. $script = $script.'var mymap = L.map("testMap").setView([0, 0], 2);';
  50. $script = $script.'L.tileLayer("https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw", {
  51. maxZoom: 15,
  52. attribution: "Map data &copy; <a href=\"https://www.openstreetmap.org/\">OpenStreetMap</a> contributors, " +
  53. "<a href=\"https://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>, " +
  54. "Imagery © <a href=\"https://www.mapbox.com/\">Mapbox</a>",
  55. id: "mapbox.streets"
  56. }).addTo(mymap);';
  57. $script = $script.'var popup = L.popup();';
  58.  
  59. foreach (glob($rep."*.jpg") as $filename){
  60. $exif = exif_read_data($filename, 0, true);
  61. if (array_key_exists("GPS",$exif)){
  62. $lon = getGps($exif["GPS"]["GPSLongitude"], $exif["GPS"]["GPSLongitudeRef"]);
  63. $lat = getGps($exif["GPS"]["GPSLatitude"], $exif["GPS"]["GPSLatitudeRef"]);
  64. $tag = "\"<img src='".$filename."' alt='Image de la position'>\"";
  65. $script = $script.'L.marker(['.$lat.', '.$lon.']).addTo(mymap).bindPopup('.$tag.').closePopup();';
  66. }
  67. }
  68.  
  69. $script = $script."</script>";
  70. echo $script;
  71. ?>
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement