-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaflet-basico.html
63 lines (56 loc) · 1.78 KB
/
leaflet-basico.html
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
<html lang="es">
<head>
<title>Leaflet básico</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="autor" />
<meta name="description" content="descripción página">
<meta name="robots" content="index,follow">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
}
#map {
height: 100%;
width: 100%;
}
</style>
<script>
var map, capa1;
function init() {
map = L.map("map", {
center: [41.6863, 1.8382],
zoom: 8
});
capa1 = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
{
maxZoom: 19,
minZoom: 1,
attribution: "Open Street Maps"
});
capa1.addTo(map);
L.marker([41.3954, 2.16859],{opacity:0.5}).addTo(map)
.bindPopup('Ciudad maravilla')
.openPopup();
map.on('click', function (e) {
console.info(e);
new L.circleMarker(e.latlng, {
color: '#ffffff',
fillColor: '#00ff00',
fillOpacity: 0.9,
radius: 8
}).addTo(map)
.bindPopup((e.latlng.lat).toFixed(4) + "," + ((e.latlng.lng).toFixed(4)))
.openPopup();
});
}
</script>
</head>
<body onLoad="init()">
<div id="map"></div>
</body>
</html>