B. Geolocalización
1 | <!DOCTYPE html> |
2 | <html lang="es"> |
3 | |
4 | <head> |
5 | |
6 | <meta charset="UTF-8"> |
7 | <meta name="viewport" |
8 | content="width=device-width"> |
9 | |
10 | <title>GPS</title> |
11 | |
12 | <style> |
13 | html { |
14 | color-scheme: light dark; |
15 | } |
16 | </style> |
17 | |
18 | </head> |
19 | |
20 | <body> |
21 | |
22 | <h1>GPS</h1> |
23 | |
24 | <p> |
25 | <label> |
26 | Latitud |
27 | <output id="latitud"></output> |
28 | </label> |
29 | </p> |
30 | |
31 | <p> |
32 | <label> |
33 | Longitud |
34 | <output id="longitud"></output> |
35 | </label> |
36 | </p> |
37 | |
38 | <script> |
39 | |
40 | navigator.geolocation. |
41 | watchPosition(p => { |
42 | |
43 | latitud.value = |
44 | p.coords.latitude |
45 | |
46 | longitud.value = |
47 | p.coords.longitude |
48 | |
49 | }); |
50 | |
51 | </script> |
52 | |
53 | </body> |
54 | |
55 | </html> |
skip_previous
skip_next