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

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


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.


                <div id="map" class="map"></div>
<div id="mousePosition"></div>
    This examples shows how to use WMTS tiles in the new LV95 frame (<a href="" target="_blank">EPSG:2056</a>).<br>
    <p>The WMTS tiles are reframed <em>on-the-fly</em> using <a href="">MapProxy</a> and the NTv2 <a href=""> CHENyx06 triangular transformation network </a>. Hence the accuracy is well beyond the resolution of the displayed layers. Without this you would see in region like the south Ticino and the Poschiavo area, a shift up to 1.5 meters between the old and the new frame. See <a href="//" target="_blank">LV95 Coordinate changes</a> for some background informations.</p>
    <p>Have a look at what <a href="//" target="_blank" >projections are available</a>.</p>


                body {
  margin: 0;
  padding: 0;

.map {
  height: 350px;

.ol-attribution.ol-uncollapsible {
  height: 1.5em;

#mousePosition {
  position: relative;
  height: 20px;
  width: 100%;


                var RESOLUTIONS = [
  4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250, 2000, 1750, 1500, 1250,
  1000, 750, 650, 500, 250, 100, 50, 20, 10, 5, 2.5, 2, 1.5, 1, 0.5
var extent = [2420000, 130000, 2900000, 1350000];
var projection = ol.proj.get('EPSG:2056');

var matrixIds = [];
for (var i = 0; i < RESOLUTIONS.length; i++) {

var wmtsSource = function(layerConfig) {
  var resolutions = layerConfig.resolutions || RESOLUTIONS;
  var tileGrid = new ol.tilegrid.WMTS({
    origin: [extent[0], extent[3]],
    resolutions: resolutions,
    matrixIds: matrixIds
  var extension = layerConfig.format || 'png';
  var timestamp = layerConfig['timestamps'][0];
  return new ol.source.WMTS(({
    attributions: [new ol.Attribution({
      html: '<a target="new" href="' +
    url: '//{Layer}/default/' + timestamp + '/2056/{TileMatrix}/{TileCol}/{TileRow}.'+ extension,
    tileGrid: tileGrid,
    projection: projection,
    layer: layerConfig.serverLayerName,
    requestEncoding: 'REST'

// See
var layerConfig = {
  "attribution": "swisstopo",
  "format": "jpeg",
  "serverLayerName": "ch.swisstopo.swissimage",
  "attributionUrl": "",
  "label": "SWISSIMAGE",
  // Use 'current', if you are only interested in the latest data.
  "timestamps": [

var wmtsLayer = new ol.layer.Tile({
  source: wmtsSource(layerConfig)

var wmsLayer = new ol.layer.Image({
  extent: extent,
  source: new ol.source.ImageWMS({
    url: '',
    ratio: 1.0,
    projection: 'EPSG:2056',
    params: {
      'LAYERS': ['org.epsg.grid_21781,org.epsg.grid_4326'],
      'FORMAT': 'image/png',
      'TILED': false
    serverType: 'mapserver'

var map = new ol.Map({
  layers: [wmtsLayer, wmsLayer],
  target: 'map',
  view: new ol.View({
    center: [2720000, 1095000],
    projection: projection,
    resolution: 100
  controls: ol.control.defaults({
    attributionOptions: ({
      collapsible: false
    new ol.control.ScaleLine({
      units: 'metric'
    new ol.control.MousePosition({
      coordinateFormat: ol.coordinate.createStringXY(4),
      //projection: 'EPSG:2056',
      target: document.getElementById('mousePosition'),
      undefinedHTML: '&nbsp;'
  logo: false,