Pen Settings



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


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


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.


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.


                <!-- loading screen -->
<div id="back-cover">
   <h1>Map Loading ...</h1>
   <i class="fa fa-circle-o-notch fa-spin fa-3x"></i>   
<!-- container for map -->
<div id="map"></div>
<!-- error message modal -->
<div class="modal fade" id="layerErrorModal" tabindex="-1" role="dialog" aria-labelledby="layerErrorModal" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Error Adding Layers</h4>
      <div id="erMsg" class="modal-body">
         <h4 class="text-danger">Warning: Some layers may not appear on map!</h4>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>        


#map {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;

/* loading screen */
#back-cover {
    background: rgba(191, 191, 191, 1);
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    display: -webkit-box;   
    display: -moz-box;      
    display: -ms-flexbox;   
    display: -webkit-flex;  
    display: flex;    
    -webkit-box-orient: vertical;
    -moz-box-orient: vertical;
    -ms-flex-direction: column;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center; 
    -moz-box-align: center; 
    -ms-flex-align: center; 
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center; 
    -moz-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;    
    color: #222;
    z-index: 1500;

#back-cover h1 {
    font-weight: bold;
    font-size: 1.75em;

/* error message modal */
#layerErrorModal {
   display: none;
   z-index: 2000;

.modal-content {
   width: 900px;
   max-width: 100%;
   word-wrap: break-word;
   padding: 15px;


                'use strict';

// Create Map object
const map ='map', {
   center: [40.15, -77.25],
   zoom: 10,               

// Set base map to Open Street Map and add to map 
const osm = L.tileLayer('//{s}{z}/{x}/{y}.png', {
    attribution: '&#169; <a href="">OpenStreetMap</a> contributors, CC BY-SA license'

// Create objects for map/feature services, but don't add to map
// Documentation states that you must add the event listener before adding layer to map
// See
// Hiking Trails - Dynamic Map Layer
const trails = L.esri.featureLayer({
   // url for service
   url: '',
   // bad URL to invoke error message
   //url: '',
   // optional attribution for source of data
   attribution: 'Cumberland County',
   // a property I added to store boolean for whether layer has loaded or not
   // used to remove loading screen
   isLoaded: false

// Planned Growth Areas - Dynamic Map Layer
const saldoPlans = L.esri.dynamicMapLayer({
   // url for service; don't forget number at the end
   url: '',
   // bad URL to invoke error message
   //url: '',
   // a property I added to store boolean for whether layer has loaded or not
   // used to remove loading screen
   isLoaded: false

// function to handle load event for map services
// pass in map service object and access properties
// service parameter is map/feature service object
const processLoadEvent = (service) => {
   // service load event
   service.on('requestsuccess', function(e) {
      console.log(`The map service ${service.options.url} has been added to the map`);
      // set isLoaded property to true
      service.options.isLoaded = true;      
   // request error event
   service.on('requesterror', function(e) {      
      // if the error url matches the url for the map service, display error messages
      // without this logic, various urls related to the service appear
      if (e.url == service.options.url) {
         // add messages to console
         console.log(`There was an error adding ${e.url} to the map`);
         console.log(`Error code: ${e.code}; Message: ${e.message}`); 
         // set isLoaded property to false
         service.options.isLoaded = false;  
         // add messages to modal window
         let erMsgContent = `<p>There was an error adding ${e.url} to the map</p>`;
         erMsgContent += `<p>Error code: ${e.code}; Message: ${e.message}</p>`;
         // add error message to modal window
         // show modal window

// Call function to process load/error events
// Trails
// Compost Sites
// Add layers to map

// Function will remove loading screen once layers are added to map 
// loading screen element
const $backCover = $('#back-cover');
// display style property
const $backCoverDisplay = $backCover.css('display');

// test if isLoaded property for both layers is true every 2 seconds
// if it is true for both layers, remove loading screen and remove interval
const loadScreenTimer = window.setInterval(function() {
   // isLoaded property
   let trailsLoaded = trails.options.isLoaded;
   let plansSitesLoaded = saldoPlans.options.isLoaded;
   if (trailsLoaded && plansSitesLoaded) {
      // remove loading screen after 3 seconds
      window.setTimeout(function() {
      }, 3000); 
      // clear timer
}, 2000);
// Remove loading screen when warning modal is closed
$('#layerErrorModal').on('', function(e) {
   // remove loading screen
   // clear timer