v3.20.0

@tschaub tschaub released this Dec 10, 2016 · 216 commits to master since this release

Summary

The v3.20.0 release includes enhancements and fixes from 89 pull requests since the previous release.

Among the changes, take a look at the new view.animate() function. This replaces the previous map.beforeRender() and ol.animation functions with more intuitive view animations that allow for chaining together multiple transitions and support a callback on animation end. In addition, two or more maps that share a view will be animated together. See the upgrade notes and the animation example for more detail.

On the subject of view transitions, scrolling with a trackpad or magic mouse now transitions the view resolution smoothly. Instead of jumping to the next integer zoom level, trackpad or magic mouse scrolling can leave the view at a fractional zoom level. In line with this trackpad behavior, pinch zooming on touch devices also now leaves the view at a fractional zoom level (see the upgrade notes for an option to restore the old behavior).

On the rendering front, the Canvas renderer got another overhaul. This release brings back the strategy of rendering to a dedicated Canvas element per layer. If you were experiencing issues with gaps between tiles on rotated views or when zooming, this change should bring rendering improvements.

Also on the rendering front, @GaborFarkas completed a nearly 5 month effort to bring line and polygon support to the WebGL renderer. If you're interested in experimenting with WebGL for vector rendering, use renderer: 'webgl' in your map constructor.

See the full list of changes below. There are some other gems down there.

Upgrade notes

Use view.animate() instead of map.beforeRender() and ol.animation functions

The map.beforeRender() and ol.animation functions have been deprecated in favor of a new view.animate() function. Use of the deprecated functions will result in a warning during development. These functions are subject to removal in an upcoming release.

For details on the view.animate() method, see the API docs and the view animation example. Upgrading should be relatively straightforward. For example, if you wanted to have an animated pan, zoom, and rotation previously, you might have done this:

var zoom = ol.animation.zoom({
  resolution: view.getResolution()
});
var pan = ol.animation.pan({
  source: view.getCenter()
});
var rotate = ol.animation.rotate({
  rotation: view.getRotation()
});

map.beforeRender(zoom, pan, rotate);

map.setZoom(1);
map.setCenter([0, 0]);
map.setRotation(Math.PI);

Now, the same can be accomplished with this:

view.animate({
  zoom: 1,
  center: [0, 0],
  rotation: Math.PI
});

ol.Map#forEachFeatureAtPixel and ol.Map#hasFeatureAtPixel parameters have changed

If you are using the layer filter of one of these methods, please note that you now have to pass in the layer filter via an ol.AtPixelOptions object. If you are not using the layer filter the usage has not changed.

Old syntax:

map.forEachFeatureAtPixel(pixel, callback, callbackThis, layerFilterFn, layerFilterThis);

map.hasFeatureAtPixel(pixel, layerFilterFn, layerFilterThis);

New syntax:

map.forEachFeatureAtPixel(pixel, callback.bind(callbackThis), {
  layerFilter: layerFilterFn.bind(layerFilterThis)
});

map.hasFeatureAtPixel(pixel, {
  layerFilter: layerFilterFn.bind(layerFilterThis)
});

This change is due to the introduction of the hitTolerance parameter which can be passed in via this ol.AtPixelOptions object, too.

Use ol.proj.getPointResolution() instead of projection.getPointResolution()

The experimental getPointResolution method has been removed from ol.Projection instances. Since the implementation of this method required an inverse transform (function for transforming projected coordinates to geographic coordinates) and ol.Projection instances are not constructed with forward or inverse transforms, it does not make sense that a projection instance can always calculate the point resolution.

As a substitute for the projection.getPointResolution() function, a ol.proj.getPointResolution() function has been added. To upgrade, you will need to change things like this:

projection.getPointResolution(resolution, point);

into this:

ol.proj.getPointResolution(projection, resolution, point);

Note that if you were previously creating a projection with a getPointResolution function in the constructor (or calling projection.setGetPointResolution() after construction), this function will be used by ol.proj.getPointResolution().

ol.interaction.PinchZoom no longer zooms to a whole-number zoom level after the gesture ends

The old behavior of ol.interaction.PinchZoom was to zoom to the next integer zoom level after the user ends the gesture.

Now the pinch zoom keeps the user selected zoom level even if it is a fractional zoom.

To get the old behavior set the new constrainResolution parameter to true like this:

new ol.interaction.PinchZoom({constrainResolution: true})

See the pinch zoom example for a complete implementation.

Detailed changes

Downloads