The v3.7.0 release includes features and fixes from 43 pull requests since v3.6.0. To simplify the code base, there were some changes to "experimental" features. Please follow the upgrade notes to make your applications work with the latest release.
Instead of an ol.FeatureOverlay
, we now use an ol.layer.Vector
with an
ol.source.Vector
. If you previously had:
var featureOverlay = new ol.FeatureOverlay({
map: map,
style: overlayStyle
});
featureOverlay.addFeature(feature);
featureOverlay.removeFeature(feature);
var collection = featureOverlay.getFeatures();
you will have to change this to:
var collection = new ol.Collection();
var featureOverlay = new ol.layer.Vector({
map: map,
source: new ol.source.Vector({
features: collection,
useSpatialIndex: false // optional, might improve performance
}),
style: overlayStyle,
updateWhileAnimating: true, // optional, for instant visual feedback
updateWhileInteracting: true // optional, for instant visual feedback
});
featureOverlay.getSource().addFeature(feature);
featureOverlay.getSource().removeFeature(feature);
With the removal of ol.FeatureOverlay
, zIndex
symbolizer properties of overlays are no longer stacked per map, but per layer/overlay. If you previously had multiple feature overlays where you controlled the rendering order of features by using zIndex
symbolizer properties, you can now achieve the same rendering order only if all overlay features are on the same layer.
Note that ol.FeatureOverlay#getFeatures()
returned an {ol.Collection.<ol.Feature>}
, whereas ol.source.Vector#getFeatures()
returns an {Array.<ol.Feature>}
.
Until now, the API exposed two different types of ol.TileCoord
tile coordinates: internal ones that increase left to right and upward, and transformed ones that may increase downward, as defined by a transform function on the tile grid. With this change, the API now only exposes tile coordinates that increase left to right and upward.
Previously, tile grids created by OpenLayers either had their origin at the top-left or at the bottom-left corner of the extent. To make it easier for application developers to transform tile coordinates to the common XYZ tiling scheme, all tile grids that OpenLayers creates internally have their origin now at the top-left corner of the extent.
This change affects applications that configure a custom tileUrlFunction
for an ol.source.Tile
. Previously, the tileUrlFunction
was called with rather unpredictable tile coordinates, depending on whether a tile coordinate transform took place before calling the tileUrlFunction
. Now it is always called with OpenLayers tile coordinates. To transform these into the common XYZ tiling scheme, a custom tileUrlFunction
has to change the y
value (tile row) of the ol.TileCoord
:
function tileUrlFunction = function(tileCoord, pixelRatio, projection) {
var urlTemplate = '{z}/{x}/{y}';
return urlTemplate
.replace('{z}', tileCoord[0].toString())
.replace('{x}', tileCoord[1].toString())
.replace('{y}', (-tileCoord[2] - 1).toString());
}
The ol.tilegrid.TileGrid#createTileCoordTransform()
function which could be used to get the tile grid's tile coordinate transform function has been removed. This function was confusing and should no longer be needed now that application developers get tile coordinates in a known layout.
The code snippets below show how your application code needs to be changed:
Old application code (with ol.tilegrid.TileGrid#createTileCoordTransform()
):
var transform = source.getTileGrid().createTileCoordTransform();
var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
tileCoord = transform(tileCoord, projection);
return 'http://mytiles.com/' +
tileCoord[0] + '/' + tileCoord[1] + '/' + tileCoord[2] + '.png';
};
Old application code (with custom y
transform):
var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
var z = tileCoord[0];
var yFromBottom = tileCoord[2];
var resolution = tileGrid.getResolution(z);
var tileHeight = ol.size.toSize(tileSize)[1];
var matrixHeight =
Math.floor(ol.extent.getHeight(extent) / tileHeight / resolution);
return 'http://mytiles.com/' +
tileCoord[0] + '/' + tileCoord[1] + '/' +
(matrixHeight - yFromBottom - 1) + '.png';
};
New application code (simple -y - 1 transform):
var tileUrlFunction = function(tileCoord, pixelRatio, projection) {
return 'http://mytiles.com/' +
tileCoord[0] + '/' + tileCoord[1] + '/' + (-tileCoord[2] - 1) + '.png';
};
The replacement of ol.tilegrid.Zoomify
is a plain ol.tilegrid.TileGrid
, configured with extent
, origin
and resolutions
. If the size
passed to the ol.source.Zoomify
source is [width, height]
, then the extent for the tile grid will be [0, -height, width, 0]
, and the origin will be [0, 0]
.
- This combines two previously distinct functions into one more flexible call which takes either a geometry or an extent.
- Rename all calls to
fitExtent
andfitGeometry
tofit
.
When single clicking a line or boundary within the pixelTolerance
, a vertex is now created.
- #3867 - Do not require projection extent for x-wrapping tile sources (@ahocevar)
- #3635 - Create vertex on boundary single click (@bjornharrtell)
- #3806 - Do not clip canvas for vector layers when wrapping the world (@ahocevar)
- #3461 - High level Modify interaction events (@bjornharrtell)
- #3865 - ol.View#fit() (@bartvde)
- #3864 - Check projection.canWrapX() before wrapping tiles (@klokantech)
- #3863 - Handle CDATA in attribute parsing for GML format (@nhambletCCRI)
- #3860 - Update example layout. (@tschaub)
- #3861 - Don't force 'dom' renderer (@openlayers)
- #3855 - Adding an example with WMTS tiles from IGN Geoportail (@pgiraud)
- #3856 - ol.source.TileVector(): bind success function of tileLoadFunction to source (@plepe)
- #3848 - Check for exports before define. (@tschaub)
- #3845 - Prevent null array to be passed to an ol.Collection (@fredj)
- #3849 - Pad min. and sec. with leading zeros in DMS notation (@pgiraud)
- #3842 - Adding a feature-animation example (@pgiraud)
- #3833 - Enable use of custom XHR loader for TileVector sources (@bjornharrtell)
- #3834 - ArcGIS tiled example broken in Chrome (@bartvde)
- #3829 - incorrect assert message (@kzr-pzr)
- #3828 - Fix typo in upgrade notes (@ahocevar)
- #3826 - Allow custom tileGrid in ol.source.XYZ (@klokantech)
- #3815 - Simplify tilegrid API and internals (@ahocevar)
- #3820 - Make unmanaged vector layers behave more like ol.FeatureOverlay (@ahocevar)
- #3822 - Correct docs for updateWhileInteracting (@probins)
- #3818 - Make geometry.transform api stable again. (@probins)
- #3801 - Respect the tile grid's extent in ol.source.TileVector (@ahocevar)
- #3810 - Improve TileGrid documentation and examples (@ahocevar)
- #3808 - Correct typo in OverlayOptions (@probins)
- #3766 - Add a clickTolerance option to the Draw interaction (@elemoine)
- #3804 - Remove sentence that was only meant for WMTS tile grids (@ahocevar)
- #3800 - Remove further references to FeatureOverlay (@probins)
- #3780 - Only expose transformed tile coordinates to the API (@ahocevar)
- #3793 - Use 'managed' instead of 'unmanaged' in LayerState (@ahocevar)
- #3792 - Link to correct layer base class (@marcjansen)
- #3791 - Remove docs referring to removed feature overlay (@marcjansen)
- #3790 - Remove unnecessary quotes around object keys (@fredj)
- #3787 - Add 'unmanaged' to ol.layer.LayerState (@ahocevar)
- #3784 - Always write the GeoJSONFeature geometry property (@fredj)
- #3783 - Fix broken wmts-hidpi example (@ahocevar)
- #3782 - Fix assert documentation typo (@gberaudo)
- #3758 - Removal of ol.FeatureOverlay (@ahocevar)
- #3775 - Add ol-touch but keep ol-viewport className. (@pgiraud)
- #3713 - Add missing propertyNames member for olx.format.WFSWriteGetFeatureOptions (@bartvde)
- #3763 - Standardise draw/modify descriptions (@probins)