What's the Weather Like?

A tool for checking the weather.

by Emmanuel Garcia

HTML

<script src="https://maps.googleapis.com/maps/api/js?libraries=weather&amp;v=3.exp&amp;sensor=false"></script>
<div id="map-canvas" />

CSS

html, body, #map-canvas {
    height: 100%;
    margin: 0px;
    padding: 0px
}

JavaScript

var SODA_LAT = 37.8757435;
var SODA_LONG = -122.25873230000002;

function initialize() {
	var mapOptions = {
		zoom: 6,
		center: new google.maps.LatLng(SODA_LAT, SODA_LONG)
	};

	// Initialize map

	// *** REPLACE null WITH YOUR CODE ***
	var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
	assertNonNull(map, "map");

	// Initialize weatherLayer, a WeatherLayer object
	// use Fahrenheit as the unit for temperature
	// use miles per hour as the wind speed unit
	// reminder: don't forget to set weatherLayer's map

	// *** REPLACE null WITH YOUR CODE ***
	var weatherLayer = new google.maps.weather.WeatherLayer({
          temperatureUnits: google.maps.weather.TemperatureUnit.CELSIUS
        });
    weatherLayer.setMap(map);
	assertNonNull(weatherLayer, "weatherLayer");

	// Initialize cloudLayer, a CloudLayer object
	// don't forget to set cloudLayer's map!

	// *** REPLACE null WITH YOUR CODE ***
	var cloudLayer = new google.maps.weather.CloudLayer();
	assertNonNull(cloudLayer, "cloudLayer");
}

initialize();


// Don't change this code
function assertNonNull(object, name) {
    assert(object !== null, name + " is null. Initialize it!");
}

function assert(condition, message) {
    message = message || "Assertion failed!";
    if (!condition) {
        alert(message);
        throw message;
    }
}