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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

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.

HTML

            
              <div class="container">
  <div class="center-objs">
    <div id="map"></div>
    <div id="new-parent">
    </div>
  </div>
</div>
            
          
!

CSS

            
              .container {
  display:flex;
  height:100vh;
  align-items:center;
  background:#333;
}

.center-objs {
  margin:0 auto;
}
  
#map {
  width: 600px;
  height:400px;
  background: lightgrey;
}
            
          
!

JS

            
              //Creat Layer
var baseMap = new L.TileLayer('http://{s}.tiles.mapbox.com/v3/gvenech.m13knc8e/{z}/{x}/{y}.png');

var baseMapIndex = {
  "Map": baseMap
};

// Create the map
var map = new L.map('map', {
    center: new L.LatLng(39.7392, -104.9903),
    zoom: 10,
    maxZoom: 18,
    zoomControl: false, // Disable the default zoom controls.
    layers: baseMap
});

// Point style
var stationStyle = {
  opacity: 0.9,
  fillOpacity: 0.7
};

// Callback to create overlay layer
/* Creating a layer from a async call probably will be a common task.  
 * Refactor out the function to make a layer, you can use this function with multiple layers. 
 */
function createPointOverlay(data, layerName, style) {
  var overlay = L.geoJson(data, { // Make the layer from the JSON and grab the handle.
    pointToLayer: function (feature, latlng) {
    return L.circleMarker(latlng, style); 
    }
  });
  overlay.addTo(map); // Add the data to the map, now you can see the point layer.
  control.addOverlay(overlay, layerName); // Add the layer to the Layer Control.
}

// Get GeoJSON data
/* Break it down and KISS.  Get the data and call a function upon completion.
 *
 * We use a anonymous function to call the createOverlay function.  This is because the callback only has 
 * the signature with submitting one object, the JSON object.  Once called it passes to the actual function with the
 * customisation that we wanted.  This allows you to use this with multiple JSON objects served from AWS. 
 */
$.getJSON("https://s3.amazonaws.com/aws-website-homebuyerrecommendationsystemfordenver-ag706/lightrail_geojson.json", function (data) { createPointOverlay(data, "Light Rail Stations", stationStyle) });

// Create the control and add it to the map;
var control = L.control.layers(baseMapIndex); // Grab the handle of the Layer Control, it will be easier to find.
control.addTo(map);
            
          
!
999px

Console