Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                <body>
  <div class="container">
    <div class="content">
      <button onclick="getLocation()" id="get-gl-data"><i class="fa fa-globe"></i> Get geolocation data</button>
      
      <!-- This button for sending data to email, I haven't figured it out yet-->
      <button id="send-gl-data"><i class="fa fa-paper-plane"></i> Send geolocation data</button>
      <p id="location"></p>
      <div id="mapholder"></div>
    </div>
  </div>
</body>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 100%;
  height: 100%;
  font-family: 'Open Sans', sans-serif;
  background-color: rgba(0, 0, 0, .1);
  background-size: cover;
  background-position: center center;
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

p {
  margin-bottom: 30px;
  font-weight: 300;
  font-size: 24px;
}

#get-gl-data {
  margin: 30px 30px 30px 0; 
  padding: 30px;
  font-size: 24px;
  background-color: #66A3DE;
  border: 0;
  outline: 0;
  color: #f4f4f4;
  transition: all .1s ease-in-out;
  cursor: pointer;
}

#get-gl-data:hover {
  opacity: .7;
}

#get-gl-data:active {
  transform: scale(.95);
}

#send-gl-data {
  margin: 30px 30px 30px 0;
  padding: 30px;
  font-size: 24px;
  background-color: #f26d5b;
  border: 0;
  outline: 0;
  color: #f4f4f4;
  transition: all .1s ease-in-out;
  cursor: pointer;
}

#send-gl-data:hover {
  opacity: .7;
}

#send-gl-data:active {
  transform: scale(0.95);
}
              
            
!

JS

              
                var JSONID = 0;

      // Create a JSON Object Array
      var geoLocJSON = new Array();

      var x = document.getElementById("location");

        function getLocation() {
          if (navigator.geolocation) {
            navigator.geolocation.watchPosition(showPosition);
          } else { 
            x.innerHTML = "Geolocation is not supported by this browser.";}
        }
    
        function showPosition(position) {
          x.innerHTML = "Latitude: " + position.coords.latitude + 
          "<br>Longitude: " + position.coords.longitude;

          var myJSON = {
            "id":JSONID,
            "geoLoc":{
                "latitude":position.coords.latitude,
                "longtitute":position.coords.longitude
            }
          };

          // Increments the JSONID
          JSONID++;
          geoLocJSON.push(myJSON);

          // Google intatercive map
          lat = position.coords.latitude;
          lon = position.coords.longitude;
          latlon = new google.maps.LatLng(lat, lon)
          mapholder = document.getElementById('mapholder')
          mapholder.style.height = '340px';
          mapholder.style.width = '672px';

          var myOptions = {
          center:latlon,zoom:14,
          mapTypeId:google.maps.MapTypeId.ROADMAP,
          mapTypeControl:false,
          navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}
          }
    
          var map = new google.maps.Map(document.getElementById("mapholder"), myOptions);
          var marker = new google.maps.Marker({position:latlon,map:map,title:"You are here!"});
        }

        // If error
        function showError(error) {
          switch(error.code) {
            case error.PERMISSION_DENIED:
              x.innerHTML = "User denied the request for Geolocation."
            break;

            case error.POSITION_UNAVAILABLE:
              x.innerHTML = "Location information is unavailable."
            break;

            case error.TIMEOUT:
              x.innerHTML = "The request to get user location timed out."
            break;

            case error.UNKNOWN_ERROR:
              x.innerHTML = "An unknown error occurred."
            break;
          }
        }
              
            
!
999px

Console