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).
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});
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);
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'
});
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.
- #6477 - Save and restore context when rotating (@ahocevar)
- #6475 - Use an url template for ol.source.Zoomify (@fredj)
- #6478 - Update clean-css-cli to the latest version 🚀 (@openlayers)
- #6472 - Use fixed pixel ratio for hit tolerance tests (@ahocevar)
- #6468 - Remove console.assert in ol.structs.PriorityQueue tests (@fredj)
- #6467 - Round the DPI value in ol.source.ImageArcGISRest (@fredj)
- #6466 - Small XML error in KML test (@tchandelle)
- #6410 - fixed the degreesToStringHDMS_() function to promote a seconds value … (@rjackson64840)
- #6461 - Add button to edit examples in CodePen (@tchandelle)
- #6320 - Use the 'openlayers' tag instead of 'openlayers-3' (@ahocevar)
- #6460 - Remove ol.Observable#unByKey (@fredj)
- #6463 - chore(package): update clean-css-cli to version 4.0.5 (@openlayers)
- #6459 - Use ol.coordinate.distance (@fredj)
- #6457 - Add Circle Modification (@tst-ppenev)
- #6455 - Make all @api annotations imply stability (@tschaub)
- #6452 - Remove deprecated methods (@tschaub)
- #6361 - Remove "margin" at the bottom of the canvas (@tchandelle)
- #6450 - Update coveralls to the latest version 🚀 (@openlayers)
- #6302 - Publish a package for use with ES module bundlers (@tschaub)
- #6446 - Update eslint to the latest version 🚀 (@openlayers)
- #6445 - Fix pinch zooming (@tschaub)
- #6444 - Disallow pinch zooming beyond min/max resolution (@tschaub)
- #6443 - goog.require cleanup (@openlayers)
- #6439 - Improve tile render performance (@ahocevar)
- #6442 - Fix missing goog.require (@fredj)
- #6441 - Update metalsmith-layouts to the latest version 🚀 (@openlayers)
- #6437 - Fit on circle (@tchandelle)
- #6427 - Ensure WMS width and height are always integers (@ahocevar)
- #6432 - Use ol.proj.EPSG3857.WORLD_EXTENT in ol.source.TileImage tests (@fredj)
- #6424 - Update dependencies to enable Greenkeeper 🌴 (@openlayers)
- #6422 - Don't listen twice to move and end events in ol.control.ZoomSlider (@fredj)
- #6426 - Add rewrite_polyfills to custom builds tutorial (@probins)
- #6365 - Make enums for draw and modify interactions public (@gberaudo)
- #6294 - Update code for closure-compiler v20170124 (@fredj)
- #6413 - Accept ol.StyleFunction in ol.Feature#setStyle() (@ahocevar)
- #6398 - Be more tolerant of map and position value (@fredj)
- #6399 - Small doc fix in VectorTileOptions renderMode (@tchandelle)
- #6396 - Show current year in attribution in "HERE Map Tile API" example (@chrismayer)
- #6390 - Tag deprecated functions with @deprecated (@fredj)
- #6370 - Feature apidoc, fix events and observable properties (@tchandelle)
- #6376 - Make ol.format.filter.or/and accept n filter conditions (@tsauerwein)
- #6393 - Only stop animation when animating (@ahocevar)
- #6387 - Add projection option to ol.source.Zoomify (@ahocevar)
- #6386 - Snap : only listen to change event triggered by the feature (@tchandelle)
- #6383 - Modify interaction: check if interaction is active before drawing modifying vertex (@tchandelle)
- #6381 - geojson-vt integration example (@drnextgis)
- #6373 - Use the ol.DEBUG_WEBGL flag to debug shader sources (@tschaub)
- #6379 - Set the overview map target in ol.control.OverviewMap.setMap (@fredj)
- #6375 - Use present in license text (@bartvde)
- #6371 - Adjust copyright to include 2017 (@kolosov-sergey)
- #6364 - Make sure moveTo is called after beginPath (@ahocevar)
- #6285 - Make size argument of ol.View#calculateExtent() optional (@ahocevar)
- #6357 - Fix GeoJSONCRSCode definition (@fredj)
- #6362 - Remove empty file (@fredj)
- #6358 - Ensure polygons without stroke are fully filled (@ahocevar)
- #6356 - Bring custom builds tutorial up to date (@probins)
- #6359 - When applying a pending fill, also apply a pending stroke (@ahocevar)
- #6360 - Remove ol.array.flatten function (@openlayers)
- #6353 - API doc : add highlight style to the active anchor (@tchandelle)
- #6355 - Remove test.geojson which was accidently committed in 57342a6 (@ahocevar)
- #6349 - Better documentation for icon-color example (@ahocevar)
- #6351 - Only consider pointerdown event if the last pointerup has been emitted (@tchandelle)
- #6345 - Mitigate rounding errors in GetMap width/height calculation (@giohappy)
- #6344 - No special raster reprojection handling for Chrome (@ahocevar)
- #6339 - Code cleanup (@fredj)
- #6337 - Constrain center in DragZoom interaction (@tchandelle)
- #6336 - Remove unused ol.format.Feature.getExtensions function (@fredj)
- #6333 - Use API key for Thunderforest resources (@ahocevar)
- #6300 - Add missing hidpi option for ol.source.ImageArcGISRest (@fredj)
- #6109 - Export Map as PNG (IE issue) (@NaveenKY)
- #6332 - Constrain the center in zoomByDelta (@tchandelle)
- #6331 - Remove unused map parameter from ol.interaction.Interaction (@tchandelle)
- #6326 - Add lineDashOffset to stroke style (@tchandelle)
- #6328 - ol.geom.polygon documentation update on the coordinates format (@quentin-ol)
- #6324 - Ensure resolution stays in range when pinching (@tschaub)
- #6329 - Fix WMTS theme location for sea-levels layer (@thomasmoelhave)
- #6323 - Fix typo in Introduction (@hdsnet)
- #6305 - Moved hit Tolerance parameter to own example. (@KlausBenndorf)
- #6319 - Remove the '3' from OpenLayers (@ahocevar)
- #6314 - WebGL conditional compilation (@ahocevar)
- #6313 - Remove ol.DEBUG (@tschaub)
- #6317 - Update sinon to version 1.17.7 🚀 (@openlayers)
- #6312 - Make layers responsible for creating layer renderers (@tschaub)
- #6308 - Dedicated modules for shared enums (@tschaub)
- #6307 - Dedicated modules for enums (@tschaub)
- #6297 - Update resemblejs to version 2.2.3 🚀 (@openlayers)
- #6296 - Fix #6295. Update reference link in sphere.js (@jbelien)
- #6255 - Don't reset the css cursor if it's not needed (@fredj)
- #6290 - Use interim tiles (@ahocevar)
- #6291 - Document olx.AtPixelOptions#hitTolerance default value (@fredj)
- #6283 - Avoid modifying coordinate in forEachLayerAtCoordinate (@tschaub)
- #6278 - Add missing require for ol.View (@tschaub)
- #6280 - Continue loading tiles when image is not ready yet (@ahocevar)
- #6277 - Name modules more like their provide (@tschaub)
- #6264 - Remove the requirement to provide a size to ol.View#fit() (@ahocevar)
- #6274 - Update clean-css to version 3.4.23 🚀 (@openlayers)
- #6269 - Update derequire to version 2.0.6 🚀 (@openlayers)
- #6270 - Add a magnify example (@tschaub)
- #6261 - Fit Zoomify view to image extent (@ahocevar)
- #6259 - Simplify Zoomify example (@ahocevar)
- #6260 - Enhance documentation for ol.View#fit (@marcjansen)
- #6258 - Set geometry name properly (@ahocevar)
- #6251 - Take image pixel ratio into account for rendered resolution (@ahocevar)
- #6244 - Enforces spacing around commas (@fredj)
- #6246 - Re-render vector tiles when layer has changed (@ahocevar)
- #6243 - Consistent spacing between keys and values in object literal (@fredj)
- #6238 - Update eslint to version 3.12.1 🚀 (@openlayers)
- #6236 - Update clean-css to version 3.4.22 🚀 (@openlayers)