Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="weatherAPI">
 <input id="cityName" type="text" placeholder="Enter City Destination">
 <button type="buton" onclick="getSingleDay()" class="apiBtn">Get Forecast</button>
 <div id="temp"></div>
</div>

<div class="forecastAPI">
 <input id="sevenDay" type="text" placeholder="City or Zip">
 <button type="buton" onclick="getForecast()" class="apiBtn">Get 3 Day Forecast</button>
 <div id="multiDay"></div>
	<div id="maps"></div>
</div>
              
            
!

CSS

              
                .weatherAPI {
	margin: 20px auto 0 auto;
	max-width: 600px;
	text-align: center;
	padding: 10px 0;
	position: relative;
}
.forecastAPI {
	margin: 0 auto 20px auto;
	max-width: 600px;
	text-align: center;
	padding: 10px 0 0 0;
	position: relative;
}
.apiBtn {
	color: #2b3d52;
	position: absolute;
	background-color: #f5f5f5;
	right: 18px;
	text-align: center;
	top: 10px;
	cursor: pointer;
	font-size: 11pt;
	padding: 6px 10px;
	margin-left: 15px;
	-webkit-border-radius: 0;
	-moz-border-radius: 0;
	border-radius: 0;
}
.weatherAPI .apiBtn,
.forecastAPI .apiBtn {
	position: static;
}
#temp {
	margin: 20px 0 10px 0;
	font-size: 12pt;
	text-align: left;
	padding: 0 20px;
	line-height: 25px;
}
.weatherAPI input, .forecastAPI input {
	padding: 6px 0;
	text-align: center;
	display: inline-block;
	text-transform: capitalize;
	font-size: 11pt;
}
.fahrenheit {
	font-size: 11pt;
	margin: 0 0 0 1px;
}
#multiDay {
	margin: 20px 0 0 30px;
	line-height: 30px;
	letter-spacing: 0.5pt;
	text-align: left;
}
#maps {
    width: 100%;
		margin-top: 20px;
    height: 300px;
		display: none;
}

@media screen and (max-width: 768px) {
	.weatherAPI {
		display: none;
	}
}

              
            
!

JS

              
                var myDate = new Date(),
		time = myDate.toLocaleTimeString(),
		month = myDate.getMonth(),
		months = [ "Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" ],
		today = myDate.getDate(),
		year = myDate.getFullYear();

// SINGLE DAY
function getSingleDay() {
	var cityName = $("#cityName").val();
	var url = "https://api.openweathermap.org/data/2.5/weather?q=" + cityName + "&appid=5fa988728912c96f18d5abbb35a0a12f";
	$.getJSON(url, weatherCallback);
	function weatherCallback(weatherData) {
		var cityName = weatherData.name,
			country = weatherData.sys.country,
			Fahrenheit = Math.ceil((weatherData.main.temp - 273.15) * 1.8) + 32,
			Celcius = Math.ceil(weatherData.main.temp - 273.15).toFixed(0);
		$("#temp").html( "The temperature in " + cityName + " (" + country + ") is " + Fahrenheit + "<span class='fahrenheit'>&#8457;</span>" + " • " + Celcius + "<span class='fahrenheit'>&#8451;</span>" );
		$("#temp").append( "<br>" + "Humidity: " + weatherData.main.humidity + "<span class='fahrenheit'>%</span>" );
		$("#temp").append( "<br><br>" + "Requested at " + time + ", " + months[month] + " " + today + ", " + year );
	}
}

/* MULTIPLE DAYS */
function getForecast() {
	var cityID = $("#sevenDay").val(),
			multiDay = document.getElementById("multiDay"),
			multipleDay = "https://api.openweathermap.org/data/2.5/forecast/daily?q=" + cityID + "&appid=409cc3736e4fa7176890bed5e9656117";
	$.getJSON(multipleDay, weatherCallback);
	function weatherCallback(forecast) {
		var lon = forecast.city.coord.lon,
				lat = forecast.city.coord.lat,
				myMap = document.getElementById('maps'),
				mapOptions = {
					center: new google.maps.LatLng(lat, lon),
					zoom: 10,
					mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("maps"), mapOptions);
		myMap.style.display = "block";
		multiDay.innerHTML = forecast.city.name + ", " + forecast.city.country + "<br>";
		for (var i = 0; i < 3; i++) {
			multiDay.innerHTML += "<b>" +
				months[month] + " " + (today + i) + "</b>: Temp(F): " +
				(Math.ceil((forecast.list[i].temp.max - 273.15) * 1.8) + 32) +
				", Temp(C): " + Math.ceil((forecast.list[i].temp.max - 273.15).toFixed(0)) +
				", Humidity: " + forecast.list[i].humidity + "<br>";
		}
	}
}

              
            
!
999px

Console