Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class = 'container-fluid text-center'>
    <!-- -->
            <div id="map-canvas"></div>
            <div class = 'block'>
                <h2>Your Local Weather</h2>
                <h3 id = 'location'>City, Country</h3>
                <div id = 'img'></div>
                <h3 id = 'temp'>--</h3>
                <a id = 'f' class = 'btn btn-primary'>F&deg</a>
                <a id = 'c' class = 'btn'>C&deg</a>
            <h4 id = 'description'>description</h3>
            <div class = 'block'>
                <div class = 'row'>
                    <div class = 'col-sm-4'>
                        <h4 id = 'windSpeed'>windSpeed</h4>
                    <div class = 'col-sm-4'>
                        <h4 id = 'humidity'>Humidity</h4>
                    <div class = 'col-sm-4'>
                        <h4 id = 'precipitation'>Precipitation</h4>
            <div class = 'block'>
                <h4>7 Day Forecast</h4>
                <div id = 'forecast' class = 'row'></div>
               body {
    background: url('') no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    color: white;

    background-color: black;
    width: 500px;
    margin: 20px auto;
    border-radius: 10px;
    opacity: .7;

    background-color: red;
    opacity: .7;
    width: 500px;
    height: auto;
    margin: 20px auto;
    border-radius: 20px;
    color: white;

    padding-top: 20px;

    padding: 5px;

    width: 200px;
    height: 200px;
    color: white;

    color: white;
    width: 50px;
    height: 50px;

    padding-left: 35px;
    padding-right: 35px;

#f, #c{
    margin-bottom: 20px;
              $(document).ready(function() {
    //used in url to gain JSON data from DarkSky API
    var lon;
    var lat;

    //Farhenheit and Celsius temps
    var fTemp;
    var cTemp;

    //hold the icon type
    var icon;

    //all attributes that will be filled from API and displayed on page
    var humidity;
    var precipitation;
    var description;
    var windSpeed;
    var iconURL;
    var location;

    //used in 7 day forecast, stores high and low temp as well as icon type
    function Day(low, high, icon){
        this.low = low;
        this.high = high;
        this.icon = icon;

    //Day objects will be pushed to this array
    var forecast = [];

    //stores the url's of each icon
    var background = {    "clear-day": "",
                          "clear-night": "",                               "partly-cloudy-day":"",
                          "partly-cloudy-night": "",
                          "cloudy": "",
                          "rain": "",
                          "sleet": "",
                          "snow": "",
                          "wind": "",
                          "fog": ""}

    //if geolocation is found
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
        lat = position.coords.latitude;
        lon = position.coords.longitude;

        //concat lat and long values into api url
        var url =
            "" +
            lat +
            "," +
            lon +

        //url for the google location API
        var address_url = "" + lat + "," + lon + "&key=AIzaSyBdnp8x3XrCjeJDlUJCMgI4zcfA_Zmm9Z0";

        //change location text
        $.getJSON(address_url, function(address_data) {
            location = address_data.results[4].formatted_address;


        $.getJSON(url, function(data) {
            fTemp = Math.round(data.currently.temperature);
            icon = data.currently.icon;
            description = data.currently.summary;
            windSpeed = data.currently.windSpeed;
            cTemp = Math.round((fTemp - 32) * (5/9));
            humidity = data.currently.humidity;
            precipitation = data.currently.precipProbability;

            for(var i = 0; i < 7; i++){
                var forecast_icon =[i+1].icon;
                var low = Math.round([i+1].temperatureMin);
                var high = Math.round([i+1].temperatureMax);

                for(var key in background){
                    if(key === forecast_icon){
                    forecast_icon = background[key];

                var new_day = new Day(low, high, forecast_icon);


                $('#temp').text(fTemp + ' degrees');

                $('#temp').text(cTemp + ' degrees');

                $('#temp').text(fTemp + ' degrees');

                $('#temp').text(cTemp + ' degrees');

            $('#windSpeed').text('Wind Speed: ' + windSpeed + ' mph' );
            $('#humidity').text('Humidity: ' + humidity);
            $('#precipitation').text('Precipitation: ' + precipitation + '%');

            for(var key in background){
                if(key === icon){
                    iconURL = background[key];

            $('#img').append("<img src = '" + iconURL + "' class = 'icon'>");

            for(var j = 0; j < 7; j++){
              $('#forecast').append('<div class = "col-sm-1 forecast_box"><img src = ' + forecast[j].icon + ' class = "forecast_icon"><p>' + forecast[j].low + '/' + forecast[j].high + '</p></div>');

        alert("No Geolocation found");
  // Styles for map
    let styles = [

        // Hide Google's labels
            featureType: "all",
            elementType: "labels",
            stylers: [
                {visibility: "off"}

        // Hide roads
            featureType: "road",
            elementType: "geometry",
            stylers: [
                {visibility: "off"}


    // Options for map
    let options = {
        center: {lat: 41.3184, lng: -72.9318}, // New Haven, CT
        disableDefaultUI: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        maxZoom: 14,
        panControl: true,
        styles: styles,
        zoom: 13,
        zoomControl: true

    // Get DOM node in which map will be instantiated
    let canvas = $("#map-canvas").get(0);

    // Instantiate map
    map = new google.maps.Map(canvas, options);

    // Configure UI once Google Map is idle (i.e., loaded)
    google.maps.event.addListenerOnce(map, "idle", configure);


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.