forked from qwerty/tupali
96 lines
2.5 KiB
PHP
96 lines
2.5 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset=utf-8 />
|
|
<title>Mapa tupale.co</title>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
|
|
<style>
|
|
body { margin:0; padding:0; }
|
|
#map {width: 100%;height: 280px;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
|
|
|
|
<div id='map'></div>
|
|
<?php
|
|
if ($_REQUEST['lat'] !='') {$lat=$_REQUEST['lat'];}else {$lat= "-72";}
|
|
if ($_REQUEST['lon'] !='') {$lon=$_REQUEST['lon'];}else {$lon= "4";}
|
|
if ($_REQUEST['zoom'] !='') {$zoom=$_REQUEST['zoom'];}else {$zoom= "18";}
|
|
|
|
if($zoom <1) {$zoom ='12';}
|
|
?>
|
|
<script>
|
|
var map = L.map('map').setView([<?php echo $lon ?>, <?php echo $lat ?>], <?php echo $zoom ?>);
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
|
|
<?php
|
|
if(!isset($_REQUEST['exif'])) { ?>
|
|
|
|
function onLocationFound(e) {
|
|
var radius = e.accuracy / 2;
|
|
var marker = L.marker(e.latlng,{draggable: true}).addTo(map)
|
|
L.circle(e.latlng, radius).addTo(map);
|
|
var mapa = window.parent.document.getElementById('<?php echo $_REQUEST[id]?>');
|
|
//var m = e.latlng;
|
|
map.setView([e.latlng.lat,e.latlng.lng], <?php echo $zoom ?>);
|
|
marker.on('dragend', ondragend);
|
|
ondragend();
|
|
//var z = 12;
|
|
function ondragend() {
|
|
var m = marker.getLatLng();
|
|
var z = map.getZoom();
|
|
if (z < '1' ) { var z = '12' ; }
|
|
mapa.value= m.lng+' '+m.lat+' '+z;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLocationError(e) {
|
|
|
|
|
|
var marker = L.marker([<?php echo $lon ?>,<?php echo $lat ?>],{draggable: true}).addTo(map);
|
|
var mapa = window.parent.document.getElementById('<?php echo $_REQUEST[id]?>');
|
|
map.setView([<?php echo $lon ?>, <?php echo $lat ?>], <?php echo $zoom ?>);
|
|
marker.on('dragend', ondragend);
|
|
ondragend();
|
|
function ondragend() {
|
|
var m = marker.getLatLng();
|
|
var z = map.getZoom();
|
|
mapa.value= m.lng+' '+m.lat+' '+z;
|
|
}
|
|
}
|
|
map.on('locationfound', onLocationFound);
|
|
map.on('locationerror', onLocationError);
|
|
|
|
|
|
map.locate({setView: true, maxZoom: 16});
|
|
|
|
<?php } else{?>
|
|
|
|
|
|
var marker = L.marker([<?php echo $lon ?>,<?php echo $lat ?>],{draggable: true}).addTo(map);
|
|
var mapa = window.parent.document.getElementById('<?php echo $_REQUEST[id]?>');
|
|
|
|
map.setView([<?php echo $lon ?>, <?php echo $lat ?>], <?php echo $zoom ?>);
|
|
marker.on('dragend', ondragend);
|
|
ondragend();
|
|
function ondragend() {
|
|
var m = marker.getLatLng();
|
|
var z = map.getZoom();
|
|
mapa.value= m.lng+' '+m.lat+' '+z;
|
|
}
|
|
|
|
|
|
<?php }?>
|
|
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html>
|