Releases: openlayers/openlayers
5.0.2
5.0.1
The v5.0.1 release helps reduce bundle sizes for bundlers that support the "sideEffects": "false"
option in package.json
, and fixes website documentation regarding cdn locations and debug build which has been replaced by source maps.
Fixes
v5.0.0
v5.0.0
The main theme of the v5.0.0 release is an improved developer/user experience with OpenLayers. Toward this end, we have reworked the library as a set of ES Modules, completely removing any dependency on the Closure Compiler, and improving compatibility with mainstream module bundlers.
See the hosted examples, API docs, and bundle tutorial for the new syntax, but basic usage looks like this:
import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new OSM()
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
See below for specific notes on upgrading from 4.x releases. We'll be working on updating the website with improved documentation and examples. Take a look at the issue tracker if you're interested in contributing.
Upgrade Notes
Renamed ol/source/TileUTFGrid
to ol/source/UTFGrid
The module name is now ol/source/UTFGrid
(ol.source.UTFGrid
in the full build).
Renaming of the defaultDataProjection
in the options and property of the ol/format/Feature
class and its subclasses
The defaultDataProjection
option is now named dataProjection
. The protected property available on the class is also renamed.
transition
option of ol/source/VectorTile
is ignored
The transition
option to get an opacity transition to fade in tiles has been disabled for ol/source/VectorTile
. Vector tiles are now always rendered without an opacity transition.
ol/style/Fill
with CanvasGradient
or CanvasPattern
The origin for gradients and patterns has changed from the top-left corner of the extent of the geometry being filled to 512 css pixel increments from map coordinate [0, 0]
. This allows repeat patterns to be aligned properly with vector tiles. For seamless repeat patterns, width and height of the pattern image must be a factor of two (2, 4, 8, ..., 512).
Removal of the renderer option for maps
The renderer
option has been removed from the Map
constructor. The purpose of this change is to avoid bundling code in your application that you do not need. Previously, code for both the Canvas and WebGL renderers was included in all applications - even though most people only use one renderer. The Map
constructor now gives you a Canvas (2D) based renderer. If you want to try the WebGL renderer, you can import the constructor from ol/WebGLMap
.
Old code:
import Map from 'ol/Map';
const canvasMap = new Map({
renderer: ['canvas']
// other options...
});
const webglMap = new Map({
renderer: ['webgl']
// other options...
});
New code:
import Map from 'ol/Map';
import WebGLMap from 'ol/WebGLMap';
const canvasMap = new Map({
// options...
});
const webglMap = new WebGLMap({
// options...
});
Removal of ol.FeatureStyleFunction
The signature of the vector style function passed to the feature has changed. The function now always takes the feature
and the resolution
as arguments, the feature
is no longer bound to this
.
Old code:
feature.setStyle(function(resolution) {
var text = this.get('name');
...
});
New code:
feature.setStyle(function(feature, resolution) {
var text = feature.get('name');
...
});
Changed behavior of the Draw
interaction
For better drawing experience, two changes were made to the behavior of the Draw interaction:
- On long press, the current vertex can be dragged to its desired position.
- On touch move (e.g. when panning the map on a mobile device), no draw cursor is shown, and the geometry being drawn is not updated. But because of 1., the draw cursor will appear on long press. Mouse moves are not affected by this change.
Changes in proj4 integration
Because relying on a globally available proj4 is not practical with ES modules, we have made a change to the way we integrate proj4:
- The
setProj4()
function from theol/proj
module was removed. - A new
ol/proj/proj4
module with aregister()
function was added. Regardless of whether the application importsproj4
or uses a globalproj4
, this function needs to be called with the proj4 instance as argument whenever projection definitions were added to proj4's registry with (proj4.defs
).
It is also recommended to no longer use a global proj4
. Instead,
npm install proj4
and import it:
import proj4 from 'proj4';
Applications can be updated by importing the register
function from the ol/proj/proj4
module
import {register} from 'ol/proj/proj4'
and calling it before using projections, and any time the proj4 registry was changed by proj4.defs()
calls:
register(proj4);
Removal of logos
The map and sources no longer accept a logo
option. Instead, if you wish to append a logo to your map, add the desired markup directly in your HTML. In addition, you can use the attributions
property of a source to display arbitrary markup per-source with the attribution control.
Replacement of ol/Sphere
constructor with ol/sphere
functions
The ol/Sphere
constructor has been removed. If you were using the getGeodesicArea
method, use the getArea
function instead. If you were using the haversineDistance
method, use the getDistance
function instead.
Examples before:
// using ol@4
import Sphere from 'ol/sphere';
var sphere = new Sphere(Sphere.DEFAULT_RADIUS);
var area = sphere.getGeodesicArea(polygon);
var distance = sphere.haversineDistance(g1, g2);
Examples after:
// using ol@5
import {circular as circularPolygon} from 'ol/geom/Polygon';
import {getArea, getDistance} from 'ol/sphere';
var area = getArea(polygon);
var distance = getDistance(g1, g2);
var circle = circularPolygon(center, radius);
New signature for the circular
function for creating polygons
The circular
function exported from ol/geom/Polygon
no longer requires a Sphere
as the first argument.
Example before:
// using ol@4
import Polygon from 'ol/geom/polygon';
import Sphere from 'ol/sphere';
var poly = Polygon.circular(new Sphere(Sphere.DEFAULT_RADIUS), center, radius);
Example after:
// using ol@5
import {circular as circularPolygon} from 'ol/geom/Polygon';
var poly = circularPolygon(center, radius);
Removal of optional this arguments.
The optional this (i.e. opt_this) arguments were removed from the following methods. Please use closures, the es6 arrow function or the bind method to achieve this effect (Bind is explained here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
- Collection#forEach
- geom/LineString#forEachSegment
- Observable#on, #once, #un
- Map#forEachLayerAtPixel
- source/TileUTFGrid#forDataAtCoordinateAndResolution
- source/Vector#forEachFeature, #forEachFeatureInExtent, #forEachFeatureIntersectingExtent
Map#forEachLayerAtPixel
parameters have changed
If you are using the layer filter, please note that you now have to pass in the layer filter via an AtPixelOptions
object. If you are not using the layer filter the usage has not changed.
Old syntax:
map.forEachLayerAtPixel(pixel, callback, callbackThis, layerFilterFn, layerFilterThis);
New syntax:
map.forEachLayerAtPixel(pixel, callback, {
layerFilter: layerFilterFn
});
To bind a function to a this, please use the bind method of the function (See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
This change is due to the introduction of the hitTolerance
parameter which can be passed in via this AtPixelOptions
object, too.
New Features and Fixes
- #8314 - Accept hitTolerance in map.forEachLayerAtPixel() (@simonseyock)
- #7750 - Don't assume fill for canvas polygon hit detection. (@schmidtk)
- #8305 - Update quickstart and tutorials for v5 (@ahocevar)
- #8301 - Do not render vectors in image mode (@ahocevar)
- #8302 - Ignore node_modules everywhere (@ahocevar)
- #8299 - Make classes in ol/ available as named exports from ol (@ahocevar)
- #8298 - Add README for ol package (@ahocevar)
- #8295 - Prepare for building/publishing v5 (@ahocevar)
- #8296 - Fix style documentation (@fredj)
- #8294 - Remove non-functional type checks from testing (@ahocevar)
- #8292 - Remove now unneeded single quotes in examples (@fredj)
- #8291 - Graticule code cleanup (@fredj)
- [#8287](https://github.com/openlayers/openlayer...
v5.0.0-beta.10
This is a pre-release of OpenLayers 5.0, with the purpose of just providing a full build (ol.js and ol.css).
v4.6.5
v4.6.4
v4.6.3
v4.6.2
v4.6.1
v4.6.0
v4.6.0
Summary
The 4.6 release includes enhancements and fixes from 30 or so pull requests. Headlining this release, vector layers got new textBackgroundFill
, textBackgroundStroke
and padding
options that can be used to render background boxes for text. ol.source.ImageVector
is now deprecated and replaced by a more convenient way to render vectors as images: by simply setting renderMode: 'image'
on the vector layer.
Please note that if you are using closure-util
to build your OpenLayers based application, it is time to migrate to using the ol
package and a module bundler like webpack. OpenLayers has not had a dependency on the Closure Library since the 3.19 release; and with the 5.0 release we will be moving completely away from goog.require
and goog.provide
, dropping support for closure-util
, and going with ES modules for our sources.
See the wiki about upcoming changes in 5.0 and tips on how to upgrade. We likely won't have another 4.x release before the 5.0 release. If you're interested in continuing to get feature enhancements in future releases, migrating to the ol
package now will make the transition easier.
Upgrade notes
Renamed exceedLength
option of ol.style.Text
to overflow
To update your applications, simply replace exceedLength
with overflow
.
Deprecation of ol.source.ImageVector
Rendering vector sources as image is now directly supported by ol.layer.Vector
with the new renderMode: 'image'
configuration option. Change code like this:
new ol.layer.Image({
source: new ol.source.ImageVector({
style: myStyle,
source: new ol.source.Vector({
url: 'my/data.json',
format: new ol.format.GeoJSON()
})
})
});
to:
new ol.layer.Vector({
renderMode: 'image',
style: myStyle,
source: new ol.source.Vector({
url: 'my/data.json',
format: new ol.format.GeoJSON()
})
});
Detailed changes
See below for the full list of changes.
- #7538 - removeFromLoadedExtents to remove extents that failed to load (@ahocevar)
- #7537 - Fix Draw.removeLastPoint exception when no points to remove (@walkermatt)
- #7461 - Use the matrixSet projection by default (@oterral)
- #5883 - Fixes setUrl() for WMTS sources (ol.source.WMTS) (@bylexus)
- #7531 - Update the ol package readme (@ahocevar)
- #7372 - Add method to set max cache size in ol.style.IconImageCache (@notnotse)
- #7530 - Check forward/back 1 world if wrapping (@raiyni)
- #7526 - Allow clicks to be stopped while drawing (@tschaub)
- #7524 - Snap view center to pixel (@ahocevar)
- #7521 - fix setMinZoom/setMaxZoom (@cs09g)
- #7519 - Reuse declutter tree for hit detection (@ahocevar)
- #7499 - Remove attributions from olx.FrameState instances (@openlayers)
- #7501 - Option to render vector layers as images (@ahocevar)
- #7516 - Deprecate exceedLength and replace with overflow (@ahocevar)
- #7510 - Do not fade the states layer (@ahocevar)
- #7513 - Make strokeKey safer (@ahocevar)
- #7514 - Prune the label cache less aggressively (@ahocevar)
- #7505 - Remove ol.DeviceOrientation link from API index (@fredj)
- #7497 - Use getGeometry (@nicholas-l)
- #7495 - Remove layer renderers when viewport is removed (@ahocevar)
- #7492 - Remove unneeded type cast from examples (@fredj)
- #7489 - Allow string to be passed as ol.interaction.Draw type (@fredj)
- #7445 - Load css rules from full-screen.css in examples (@fredj)
- #7481 - Make zoom to extent control extensible (@gberaudo)
- #7477 - Make text states available for replay time (@ahocevar)
- #7482 - Reset rotation after rendering (@ahocevar)
- #7480 - Create a new image when loading tile after an error (@ahocevar)
- #7476 - Reset text measurements when available fonts change (@ahocevar)
- #7454 - Add text background rendering and text padding (@ahocevar)
- #7468 - Add new API-key for HERE example (@chrismayer)
- #7465 - Export ol.proj.Projection#getAxisOrientation function (@fredj)
- #7462 - Respect metersPerUnit in ScaleLine control (@ahocevar)
Additionally a number of updates where made to our dependencies:
- #7536 - Update fs-extra to the latest version 🚀 (@openlayers)
- #7533 - Update marked to the latest version 🚀 (@openlayers)
- #7527 - Update eslint to the latest version 🚀 (@openlayers)
- #7511 - Update rollup to the latest version 🚀 (@openlayers)
- #7512 - Update eslint to the latest version 🚀 (@openlayers)
- #7484 - Update closure-util to the latest version 🚀 (@openlayers)