1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
<!DOCTYPE html>
<html>
<head>
<title>Resultat previsions</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@0.7.7/dist/leaflet.css" />
<style type="text/css">
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/leaflet@0.7.7/dist/leaflet.js"></script>
<script src="https://www.mapquestapi.com/sdk/leaflet/v2.2/mq-map.js?key=IJIOhD3abkHkZSklL6U1cPxvKaEOdOnX"></script>
<script>
function toSexagesimal(dec) {
var tmp = (Math.abs(dec) + 1.e-9).toString().split('.');
var deg = tmp[0];
var min = ('0.' + tmp[1]) * 60;
var sec = min.toString().split('.');
min = Math.floor(min);
sec = (('0.' + sec[1]) * 60).toFixed(0);
if (sec == 60) {
sec = 0;
min++;
}
if (min == 60) {
min = 0;
deg++;
}
return (deg + '° ' + ((min < 10) ? '0' + min : min) + "' " + ((sec < 10) ? '0' + sec : sec) + '"');
}
/*
var standard = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors</a>'
});
*/
var mapquest = MQ.mapLayer();
var map = L.map('map', {
center: new L.LatLng(LATITUDE_CENTRE, LONGITUDE_CENTRE), zoom: VALEUR_ZOOM,
layers: mapquest
});
var marker = new L.marker([LATITUDE_CENTRE, LONGITUDE_CENTRE]).addTo(map);
var popup = L.popup();
marker.on('mouseover', function onShowPopup(e) {
popup
.setLatLng(e.latlng)
.setContent("NOMLIEU_CENTRE<br />CHAINE_LONGITUDE : " + toSexagesimal(e.latlng.lng) + ' ' + ((e.latlng.lng < 0.) ? 'W' : 'E') +
"<br />CHAINE_LATITUDE : " + toSexagesimal(e.latlng.lat) + ' ' + ((e.latlng.lat < 0.) ? 'S' : 'N') + "<br />CHAINE_ALTITUDE : ALTITUDE_CENTRE")
.openOn(map);
});
map.on('click', function(e) {
popup
.setLatLng(e.latlng)
.setContent("CHAINE_LONGITUDE : " + toSexagesimal(e.latlng.lng) + ' ' + ((e.latlng.lng < 0.) ? 'W' : 'E') +
"<br />CHAINE_LATITUDE : " + toSexagesimal(e.latlng.lat) + ' ' + ((e.latlng.lat < 0.) ? 'S' : 'N'))
.openOn(map);
});
L.control.scale({ position: 'topright' }).addTo(map);
if (LONGITUDE1 != 0. && LATITUDE1 != 0. && LONGITUDE2 != 0. && LATITUDE2 != 0.) {
L.polygon([
[LATITUDE1, LONGITUDE1],
[LATITUDE2, LONGITUDE2]
]).addTo(map);
}
</script>
</body>
</html>
|