Show the Local Weather
How do I make an show the local weather?
What is a show the local weather? How do you make a show the local weather? This script and codes were developed by Donald on 10 September 2022, Saturday.
Show the Local Weather - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Show the Local Weather</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="jumbotron container-fluid">
<div class="box"> <p>The current temperature is: </p> <p id = "temp"></p> <button id='celsius'>Celsius</button> <button id='farenheit'>Farenheit</button> <div class='increase-margin' id='weatherIcon'></div> <p id ="theWeather"></p> <p id="city"></p>
<p><button class="btn btn-primary" onclick="geoFindMe()">Weather in my location</button></p>
<div class="box" id="out"></div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Show the Local Weather - Script Codes CSS Codes
body { background-color: lightblue; text-align:center; color: #aff;
}
.jumbotron { background-image:url('https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSg72r3fwD_LxMeODfRfKfTq4eZA9GUwU1T0IlazZCoJmUasnXU'); height: 900px; background-repeat: no-repeat; background-size: cover;
}
.box { margin: 20px; font-size: 20px; color: purple;
}
button:focus { background-color: yellow;
}
.increase-margin { margin-top: 20px;
}
Show the Local Weather - Script Codes JS Codes
var farenheit = false;
var c = 0;
var f = 0;
var api ="http://api.openweathermap.org/data/2.5/weather?lat=";
function geoFindMe() { var output = document.getElementById("out"); if (!navigator.geolocation){ output.innerHTML = "<p>Geolocation is not supported by your browser</p>"; return; } function success(position) { var lati = position.coords.latitude; var longi = position.coords.longitude; output.innerHTML = '<p>Latitude is ' + lati + '° <br>Longitude is ' + longi + '°</p>'; var img = new Image(); img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + lati + "," + longi + "&zoom=13&size=300x300&sensor=false"; output.appendChild(img); getData(lati, longi); }; function error() { output.innerHTML = "Unable to retrieve your location"; }; output.innerHTML = "<p>Locating…</p>"; navigator.geolocation.getCurrentPosition(success, error);
}
function getData (lati, longi) { $.getJSON(api + lati + "&lon=" + longi + "&units=metric&appid=ee7dc0a2f17ed13b39c894dad533f966", function(json) { t = Math.round(json.main.temp); setTemp(t); var weat = json.weather[0].main; showWeather(weat); $('#city').html(json.name + ", " + json.sys.country);
})
}
$(document).ready(function(){ getData(50, -120); geoFindMe();
});
document.getElementById('farenheit').addEventListener('click', farenheitOn);
document.getElementById('celsius').addEventListener('click', farenheitOff);
function farenheitOn() { farenheit = true; displayTemp();
}
function farenheitOff() { farenheit = false; displayTemp();
}
function setTemp(t) { c = t; f = Math.round(t * 9 / 5 + 32); displayTemp();
}
function displayTemp() { if (farenheit) { document.getElementById('temp').innerHTML = f + " F"; } else { document.getElementById('temp').innerHTML = c + " C"; }
}
function showWeather(weat) { var link = ''; switch(weat) { case 'Sunny': link = 'http://www.freeiconspng.com/uploads/sunny-icon-2.png'; break; case 'Cloudy': link = 'http://www.dailyfreepsd.com/wp-content/uploads/2013/06/Cloudy-Overcast-weather-icon-vector.png'; break; case 'Rain': link = 'http://downloadicons.net/sites/default/files/rain-icon-46110.png' break; case 'Clear': link = 'https://cdn1.iconfinder.com/data/icons/astronomy/154/astronomy-stars-moon-planet-cosmos-512.png' break; case 'Snow': link = 'http://www.freeiconspng.com/uploads/black-snow-icon-4.png'; break; }
document.getElementById('weatherIcon').innerHTML = '<img src="' + link + '" height="80" width="80" >'; document.getElementById('theWeather').innerHTML = weat;
}
![Show the Local Weather - Script Codes](http://shots.codepen.io/donaldk7/pen/XjEmEz-512.jpg)
Developer | Donald |
Username | donaldk7 |
Uploaded | September 10, 2022 |
Rating | 3 |
Size | 3,163 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Calculator | 3,226 Kb |
Twitch TV Streamer | 3,006 Kb |
Pomodoro clock | 2,859 Kb |
Quote of the Day | 2,224 Kb |
Tic Tack Toe | 3,361 Kb |
Personal Portfolio | 3,826 Kb |
Tribute page | 2,142 Kb |
Timestamp | 1,757 Kb |
A Pen by Donald | 1,274 Kb |
Simon game | 3,768 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Responsive slide | Thorien | 2,400 Kb |
Social Profiles | Lachlanjc | 1,939 Kb |
Popover | Teles | 2,248 Kb |
A Pen by Jess | Jessamyne | 5,100 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
Rotate Demo | Agelber | 3,061 Kb |
CSS eye follow | Pedrocampos | 2,592 Kb |
Background Images | Jooonebug | 2,100 Kb |
Personal Website Redesign v2.0 | DevItWithDavid | 5,168 Kb |
3D flipping card | Ssaakkaa | 2,238 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!