OpenLayers v5.x

Tim Schaub edited this page Dec 5, 2017 · 4 revisions

OpenLayers v5.x will be a set of ES modules, similar to the v4.x ol package. The difference is that from v5.0.0 on, the sources will be authored and maintained as ES modules. OpenLayers will no longer depend on and be compatible with closure-util.

Upgrade notes

Users of the v4.x ol package

Class modules will have CamelCase names, instead of the current lowercase names. This means that imports like

import Map from 'ol/map';

will change to

import Map from 'ol/Map';

We will be providing a code transform to automate this change.

In addition to that, we will be adding named exports for modules like ol/extent or ol/proj, which will allow users to import less and get smaller build sizes. The default exports of v4.x will still work though.

Users of a full build (ol.js or ol-debug.js).

The full build will still be provided, but we encourage everyone to switch to the ol package.

Users of closure-util

If you build your application together with OpenLayers using closure-util, we recommend to upgrade your application to use ES modules instead of goog.require and goog.provide.

Existing code like


MyApp.createMap = function() {
  return new ol.Map({});

will have to be changed to

import Map from 'ol/map';

export function createMap() {
  return new Map({});

Note that ES modules, other than goog.provide and goog.require, do not assume and use global namespacing.

For the build environment, you can use anything that works with ES modules. Some examples (including some that use the Closure Compiler) are linked from the ol package README.

As an interim solution, when working with webpack, the closure-loader may help to make OpenLayers 5.x work with existing closure-util based applications.

Users of custom builds

We recommend switching to a webpack based setup and import only what's needed from the ol package. See the ol package README for examples of how to setup and use OpenLayers like that for your application.

As an interim solution, you can use the full build (ol.js or ol-debug.js) instead.

Type definitions and type checking


You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.