
Ayuda con JSON
Publicado por Ela (4 intervenciones) el 09/04/2015 19:11:10
Hola, tengo un contenido de Json donde se muestra datos climáticos quisiera modificarlo para poder representar los puntos expresados en el JSON como coordenadas en un mapa.
aquí les dejo lo que he realizado, hasta ahora, les agradecería su ayuda.
Saludos.
aquí les dejo lo que he realizado, hasta ahora, les agradecería su ayuda.
Saludos.
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Acceso a API Climática mediante JSON</title>
<script type="text/javascript">
function inicio_xhr() {
if(window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
function cargaPrediccion() {
peticion = inicializa_xhr();
peticion.onreadystatechange = muestraPrediccion;
peticion.open('GET', "http://api.openweathermap.org/data/2.5/find?lat=40&lon=-2&lang=es", true);
peticion.send(null);
}
function Prediccion() {
if(peticion.readyState == 4) {
if(peticion.status == 200) {
datosClimaticos = eval("("+peticion.responseText+")");
//datosClimaticos.list[0].name?
//datosClimaticos.list[0].coord.lon?
console.log(datosClimaticos);
}
}
}
</script>
</head>
<body onload="Prediccion()">
<div id="map" style="width: 600px; height: 600px"></div>
</body>
</html>
Valora esta pregunta


0