-
Notifications
You must be signed in to change notification settings - Fork 0
/
explore.js
64 lines (55 loc) · 2.86 KB
/
explore.js
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
function selectContent(){
const body = document.getElementsByTagName('body')[0];
const select = document.getElementById("dataset-select");
if(select.value == "odiac-ffco2-monthgrid-v2023-odiac2023_1km_excl_intl_202212"){
body.style.backgroundImage = 'url(img/map1.png)';
loadMap("https://earth.gov/ghgcenter/api/raster/collections/odiac-ffco2-monthgrid-v2023/items/odiac-ffco2-monthgrid-v2023-odiac2023_1km_excl_intl_202212/map?assets=co2-emissions&rescale=-10%2C60&colormap_name=jet")
}else if(select.value == "sedac-popdensity-yeargrid5yr-v4.11-2020"){
body.style.backgroundImage = 'url(img/map2.png)';
loadMap("https://earth.gov/ghgcenter/api/raster/collections/sedac-popdensity-yeargrid5yr-v4.11/items/sedac-popdensity-yeargrid5yr-v4.11-2020/map?assets=population-density&nodata=-3.402823e%2B38&rescale=0%2C1000&colormap_name=ylorrd")
}else if(select.value == "eccodarwin-co2flux-monthgrid-v5-202212"){
body.style.backgroundImage = 'url(img/map3.png)';
loadMap("https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212/map?assets=co2&nodata=nan&rescale=-0.0007%2C0.0002&colormap_name=bwr")
}else if(select.value == "gosat-based-ch4budget-yeargrid-v1-2019"){
body.style.backgroundImage = 'url(img/map4.png)';
loadMap("https://earth.gov/ghgcenter/api/raster/collections/gosat-based-ch4budget-yeargrid-v1/items/gosat-based-ch4budget-yeargrid-v1-2019/map?assets=post-total&nodata=9.96921e%2B36&rescale=0%2C0.3&colormap_name=spectral_r")
}
}
function loadMap(url){
// // Define iframe with lazy loading
// const iframe = document.createElement("iframe");
// iframe.src = url;
// iframe.width = "100%";
// iframe.height = "100%";
// iframe.loading = "lazy";
// iframe.onload = function() {
// console.log(map)
// };
// // Add to div element with class named frameDiv
// const frameDiv = document.getElementById("iframe-container");
// frameDiv.innerHTML.innerHTML = "";
// frameDiv.append(iframe);
const iframe = document.getElementById("nasa-iframe");
iframe.src = url;
}
// // Inicializa el mapa
// var map = L.map('map').setView([0, 0], 2);
// // Añadir capa de mapa base
// L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
// maxZoom: 19
// }).addTo(map);
// map.setZoom(4)
//Función para cargar puntos desde el backend
function loadPoints() {
const select = document.getElementById("dataset-select")
fetch('https://earth.gov/ghgcenter/api/stac')
.then(response => response.json())
.then(data => {
const result = data.links.filter(d => d.rel == "child");
result.forEach(function(item) {
console.log(item.title)
});
//L.geoJSON(data).addTo(map);
});
}
loadPoints();