I use setitem(coordinates)
in a previous page that concerns latitude an longitude. I want the next page to use getItem()
but just the latitude but I didn’t get it.
First page
function storeCoordinates(location) {
const coordinates = {
lat: location.lat(),
lng: location.lng()
};
localStorage.setItem('coordinates', JSON.stringify(coordinates));
}
Next page
window.onload = function () {
var lat = localStorage.getItem('coordinates.lat');
var IR = (-75 * lat) + 5025;
var energie_pro = IR * 0.926 * 0.8 * 0.213 * 1.92 * 8;
document.getElementById('eco_3000').innerText = energie_pro;
}