Migración a Bootstrap 4
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.5KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8 />
  5. <title></title>
  6. <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
  7. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
  8. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
  9. integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
  10. crossorigin=""/>
  11. <script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
  12. integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
  13. crossorigin=""></script>
  14. -->
  15. <link rel="stylesheet" href="librerias/leaflet/leaflet.css"/>
  16. <script src="librerias/leaflet/leaflet.js"></script>
  17. <style>
  18. body { margin:0; padding:0; }
  19. #map {width: 100%;height: 280px;}
  20. </style>
  21. </head>
  22. <body>
  23. <div id='map'></div>
  24. <?php
  25. if ($_REQUEST['lat'] !='') {$lat=$_REQUEST['lat'];}else {$lat= "-72";}
  26. if ($_REQUEST['lon'] !='') {$lon=$_REQUEST['lon'];}else {$lon= "4";}
  27. if ($_REQUEST['zoom'] !='') {$zoom=$_REQUEST['zoom'];}else {$zoom= "5";}
  28. ?>
  29. <script>
  30. var map = L.map('map')
  31. .setView([<?php echo $lon ?>, <?php echo $lat ?>], <?php echo $zoom ?>);
  32. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
  33. <?php
  34. if(!isset($_REQUEST['exif'])) { ?>
  35. function onLocationFound(e) {
  36. //var radius = e.accuracy / 2;
  37. var marker = L.marker(e.latlng,{draggable: true}).addTo(map);
  38. var mapa = window.parent.document.getElementById("<?php echo $_REQUEST[id] ?>");
  39. mapa.value= '<?php echo "$lon $lat $zoom"; ?>';
  40. marker.on('dragend', ondragend);
  41. ondragend();
  42. map.setZoom(<?php echo $zoom; ?>);
  43. var m = marker.getLatLng();
  44. mapa.value= m.lng+' '+m.lat+' <?php echo $zoom; ?>';
  45. function ondragend() {
  46. var m = marker.getLatLng();
  47. var z = map.getZoom();
  48. map.setZoom(z);
  49. mapa.value= m.lng+' '+m.lat+' '+z;
  50. }
  51. }
  52. function onLocationError(e) {
  53. //alert(e.message);
  54. var marker = L.marker([<?php echo $lon ?>,<?php echo $lat ?>],{draggable: true}).addTo(map);
  55. var mapa = window.parent.document.getElementById('<?php echo $_REQUEST[id]?>');
  56. marker.on('dragend', ondragend);
  57. ondragend();
  58. function ondragend() {
  59. var m = marker.getLatLng();
  60. var z = map.getZoom();
  61. mapa.value= m.lng+' '+m.lat+' '+z;
  62. }
  63. }
  64. map.on('locationerror', onLocationError);
  65. map.on('locationfound', onLocationFound);
  66. map.locate({setView: true, maxZoom: 20});
  67. <?php }else{ ?>
  68. var marker = L.marker([<?php echo $lon ?>,<?php echo $lat ?>],{draggable: true}).addTo(map);
  69. var mapa = window.parent.document.getElementById('<?php echo $_REQUEST[id]?>');
  70. marker.on('dragend', ondragend);
  71. ondragend();
  72. function ondragend() {
  73. var m = marker.getLatLng();
  74. var z = map.getZoom();
  75. mapa.value= m.lng+' '+m.lat+' '+z;
  76. }
  77. <?php } ?>
  78. //var lat = window.parent.document.getElementById('lat');
  79. //var lng = window.parent.document.getElementById('lon');
  80. //var mapa = window.parent.document.getElementById('<?php echo $_REQUEST[id]?>');
  81. //var marker = L.marker([<?php echo $lon ?>,<?php echo $lat ?>],{draggable: true}).addTo(map);
  82. // every time the marker is dragged, update the coordinates container
  83. //marker.on('dragend', ondragend);
  84. // Set the initial marker coordinate on load.
  85. //ondragend();
  86. /*
  87. function ondragend() {
  88. var m = marker.getLatLng();
  89. var z = map.getZoom();
  90. // lat.value= m.lat;
  91. // lng.value= m.lng;
  92. mapa.value= m.lng+' '+m.lat+' '+z;
  93. }*/
  94. </script>
  95. </body>
  96. </html>