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.


                <div id="map" class="map"></div>



                .map {
  height: 500px;


                // Define NZTM projection
proj4.defs("EPSG:2193","+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +axis=neu");

// Register projection with OpenLayers

// Create new OpenLayers projection
let proj2193 = new ol.proj.Projection({
	code: 'EPSG:2193',
	units: 'm',
	extent: [274000, 3087000, 3327000, 7173000]

// Attribution Control
let attribution = new ol.control.Attribution({
				collapsible: false
let controls = ol.control.defaults({ zoom : false, attribution: false }).extend([attribution])
// Define map
let map = new ol.Map({
  layers: [],
  controls: controls,
  target: 'map',
    view: new ol.View({
      projection: proj2193,
      center: [1205684, 5032560], 
      zoom: 11

// Define WMTS parser
let parser = new ol.format.WMTSCapabilities();

// Fetch WMTS Capabilities
  .then(function(response) {
    return response.text();
}).then(function(text) {
  // Use WMTS parser to read GetCapabilities response
  let wmtsCaps =;
  // Get options from GetCapabilities response 
  let options = ol.source.WMTS.optionsFromCapabilities(wmtsCaps, {
    layer: 'topobasemap',
    matrixSet: 'NZTM2000'
  let currentYear = (new Date()).getFullYear();
  options.attributions =  ['&copy; Landcare Research NZ Limited 2009-'+currentYear+'. Contains data sourced from LINZ. Crown Copyright Reserved.']
  // Define layer using options from GetCapabilities response
  let lyr = new ol.layer.Tile({
    opacity: 1,
    source: new ol.source.WMTS((options))
  // Add layer to map