Skip to content

Latest commit

 

History

History
183 lines (159 loc) · 19.6 KB

v4.0.0.md

File metadata and controls

183 lines (159 loc) · 19.6 KB

4.0.0

Starting with this version, OpenLayers introduces Semantic Versioning. Unlike the switch from v2.x to v3.x, which marked a complete rewrite of the library with an entirely new API, major version increments now simply mean that users should pay attention to the 'Breaking changes' section of the upgrade notes.

For users of mainstream bundlers and minifiers, OpenLayers is now also available as a set of ES2015 modules. See https://npmjs.com/package/ol/. With that package, bundling only the needed parts of the library with an application is now completely hassle free.

Version 4.0.0 includes enhancements and fixes from 107 pull requests since the previous release.

Among these changes, #6381 adds an example which shows how to use geojson-vt for highly efficient rendering of GeoJSON data as vector tiles.

Several improvements were made to ol.source.Zoomify, including projection support (#6387) and support for URL templates (#6475).

Also the ol.source.ImageArcGISRest saw some enhancements, including HiDPI/Retina support and a fix that avoids non-integer DPI values (#6300 and #6467).

On the topic of drawing tools, @tst-ppenev completed an effort to make the ol.interaction.Modify interaction support modification of ol.geom.Circle geometries (#6457).

Breaking changes

Simplified ol.View#fit() API

In most cases, it is no longer necessary to provide an ol.Size (previously the 2nd argument) to ol.View#fit(). By default, the size of the first map that uses the view will be used. If you want to specify a different size, it goes in the options now (previously the 3rd argument, now the 2nd).

Most common use case - old API:

map.getView().fit(extent, map.getSize());

Most common use case - new API:

map.getView().fit(extent);

Advanced use - old API:

map.getView().fit(extent, [200, 100], {padding: 10});

Advanced use - new API:

map.getView().fit(extent, {size: [200, 100], padding 10});

Removal of deprecated methods

The deprecated ol.animation functions and map.beforeRender() method have been removed. Use view.animate() instead.

The unByKey() method has been removed from ol.Observable instances. Use the ol.Observable.unByKey() static function instead.

var key = map.on('moveend', function() { ...});
map.unByKey(key);

New code:

var key = map.on('moveend', function() { ...});
ol.Observable.unByKey(key);

Upgrade notes

Simpler ol.source.Zoomify url configuration

Instead specifying a base url, the url for the ol.source.Zoomify source can now be a template. The {TileGroup}, {x}, {y}, {z} and placeholders must be included in the url in this case. the url can now also include subdomain placeholders:

new ol.source.Zoomify({
  url: 'https://{a-f}.example.com/cgi-bin/iipsrv.fcgi?zoomify=/a/b/{TileGroup}/{z}-{x}-{y}.jpg'
});

Removed build flags (@define)

The ol.DEBUG, ol.ENABLE_TILE, ol.ENABLE_IMAGE, ol.ENABLE_VECTOR, and ol.ENABLE_VECTOR_TILE build flags are no longer necessary and have been removed. If you were using these in a define array for a custom build, you can remove them.

If you leave ol.ENABLE_WEBGL set to true in your build, you should set ol.DEBUG_WEBGL to false to avoid including debuggable shader sources.

List of all changes