Get started with ol3 CDN

BSD-2-Clause licensed

The ol3 library is a popular open-source JS mapping library for creating and working with interactive maps in the browser, using OpenLayers 3 technology.

Tags:
  • map
  • openlayers
  • maps

Stable version

Copied!

How to start using ol3 CDN


// Import OpenLayers library
const ol = document.createElement('script');
ol.src = 'https://cdn.cdnhub.io/ol3/4.6.5/ol.js';
document.head.appendChild(ol);

// Wait for OpenLayers to load
window.onload = function() {
  // Create a map in the "map" div, set the view to a given center and zoom
  const map = new ol.Map({
    target: 'map',
    layers: [
      new ol.layer.Tile({
        source: new ol.source.OSM()
      })
    ],
    view: new ol.View({
      center: [0, 0],
      zoom: 2
    })
  });
};
Copied!
Copied!
Copied!
Copied!

All versions