The 3.5.0 release includes features and fixes from a whopping 129 pull requests since 3.4.0. This release removes a number of "experimental" features from the API, so take a close look at the notes below when upgrading.
-
The following experimental methods have been removed from
ol.Object
:bindTo
,unbind
, andunbindAll
. If you want to get notification aboutol.Object
property changes, you can listen for the'propertychange'
event (e.g.object.on('propertychange', listener)
). Two-way binding can be set up at the application level using property change listeners. See #3472 for details on the change. -
The experimental
ol.dom.Input
component has been removed. If you need to synchronize the state of a dom Input element with anol.Object
, this can be accomplished using listeners for change events. For example, you might bind the state of a checkbox type input with a layer's visibility like this:var layer = new ol.layer.Tile(); var checkbox = document.querySelector('#checkbox'); checkbox.addEventListener('change', function() { var checked = this.checked; if (checked !== layer.getVisible()) { layer.setVisible(checked); } }); layer.on('change:visible', function() { var visible = this.getVisible(); if (visible !== checkbox.checked) { checkbox.checked = visible; } });
-
The following experimental vector classes have been removed:
ol.source.GeoJSON
,ol.source.GML
,ol.source.GPX
,ol.source.IGC
,ol.source.KML
,ol.source.OSMXML
, andol.source.TopoJSON
. You now will useol.source.Vector
instead.For example, if you used
ol.source.GeoJSON
as follows:var source = new ol.source.GeoJSON({ url: 'features.json', projection: 'EPSG:3857' });
you will need to change your code to:
var source = new ol.source.Vector({ url: 'features.json', format: new ol.format.GeoJSON() });
See https://openlayers.org/en/latest/examples/vector-layer.html for a real example.
Note that you no longer need to set a
projection
on the source!Previously the vector data was loaded at source construction time, and, if the data projection and the source projection were not the same, the vector data was transformed to the source projection before being inserted (as features) into the source.
The vector data is now loaded at render time, when the view projection is known. And the vector data is transformed to the view projection if the data projection and the source projection are not the same.
If you still want to "eagerly" load the source you will use something like this:
var source = new ol.source.Vector(); $.ajax('features.json').then(function(response) { var geojsonFormat = new ol.format.GeoJSON(); var features = geojsonFormat.readFeatures(response, {featureProjection: 'EPSG:3857'}); source.addFeatures(features); });
The above code uses jQuery to send an Ajax request, but you can obviously use any Ajax library.
See https://openlayers.org/en/latest/examples/igc.html for a real example.
-
Note about KML
If you used
ol.source.KML
'sextractStyles
ordefaultStyle
options, you will now have to set these options onol.format.KML
instead. For example, if you used:var source = new ol.source.KML({ url: 'features.kml', extractStyles: false, projection: 'EPSG:3857' });
you will now use:
var source = new ol.source.Vector({ url: 'features.kml', format: new ol.format.KML({ extractStyles: false }) });
-
The
ol.source.ServerVector
class has been removed. If you used it, for example as follows:var source = new ol.source.ServerVector({ format: new ol.format.GeoJSON(), loader: function(extent, resolution, projection) { var url = …; $.ajax(url).then(function(response) { source.addFeatures(source.readFeatures(response)); }); }, strategy: ol.loadingstrategy.bbox, projection: 'EPSG:3857' });
you will need to change your code to:
var source = new ol.source.Vector({ loader: function(extent, resolution, projection) { var url = …; $.ajax(url).then(function(response) { var format = new ol.format.GeoJSON(); var features = format.readFeatures(response, {featureProjection: projection}); source.addFeatures(features); }); }, strategy: ol.loadingstrategy.bbox });
See https://openlayers.org/en/latest/examples/vector-osm.html for a real example.
-
The experimental
ol.loadingstrategy.createTile
function has been renamed tool.loadingstrategy.tile
. The signature of the function hasn't changed. See https://openlayers.org/en/latest/examples/vector-osm.html for an example.
- When manually loading an image for
ol.style.Icon
, the image size should now be set with theimgSize
option and not withsize
.size
is supposed to be used for the size of a sub-rectangle in an image sprite.
The return value of ol.tilegrid.TileGrid#getTileSize()
will now be an ol.Size
array instead of a number if non-square tiles (i.e. an ol.Size
array instead of a number as tilsSize
) are used. To always get an ol.Size
, the new ol.size.toSize()
was added.
When finishing a draw, the drawend
event is now dispatched before the feature is inserted to either the source or the collection. This change allows application code to finish setting up the feature.
If you compile your application together with the library and use the ol.feature.FeatureStyleFunction
type annotation (this should be extremely rare), the type is now named ol.FeatureStyleFunction
.
- #3646 - Use graceful-fs in place of fs (@elemoine)
- #3645 - Fix test-coverage.js script (@elemoine)
- #3640 - Make make fail on requires and whitespace errors (@elemoine)
- #3644 - added altclick select to selectfeatures example (@t27)
- #3612 - Add ol.source.WMTS#getUrls and getRequestEncoding (@elemoine)
- #3616 - Add support for freehand drawing to the Draw interaction (@ahocevar)
- #3634 - Remove unused local variable (@fredj)
- #3629 - Problems with XYZ coordinates in snap interaction (@tsauerwein)
- #3633 - Add a Makefile section to .editorconfig (@elemoine)
- #3632 - Make host-examples target copy index.js (@elemoine)
- #3631 - Restore Modify interaction constructor test (@bjornharrtell)
- #3630 - Initial tests for Modify interaction vertex creation (@bjornharrtell)
- #3527 - Replace pake with make? (@elemoine)
- #3624 - Add a one sentence summary for several exportable symbols (@marcjansen)
- #3623 - OpenLayers overwrites WMS format_options instead of extending them. (@bartvde)
- #3621 - Fix typo in documentation comment (@openlayers)
- #3614 - GML2 parser does not parse all features (@bartvde)
- #3619 - Add a one sentence summary for ol.geom.* exportable symbols (@marcjansen)
- #3618 - Replace non-breaking space (U+00A0) with regular space (U+0020). (@tschaub)
- #3617 - Add ol.size.hasArea. (@tschaub)
- #3597 - Remove dead link in api doc (@fredj)
- #3613 - Add a one sentence summary for ol.interaction* exportable symbols (@marcjansen)
- #3611 - Improve error handling in Esri JSON format (@bartvde)
- #3560 - Add an example showing how to create a permalink (@tsauerwein)
- #3571 - Add wrapX support for vector layers (canvas renderer only) (@ahocevar)
- #3605 - vector-esri-edit.html uses non api method (@bartvde)
- #3602 - Rename ol.feature.FeatureStyleFunction to ol.FeatureStyleFunction. (@tschaub)
- #3604 - Add charset so that zoom out button shows correctly (@bartvde)
- #3603 - Reformat upgrade-notes.md (@elemoine)
- #3599 - Improve docs for source.Vector options (@probins)
- #3598 - Remove unnecessary entry in
.gitignore
. (@tschaub) - #3595 - Add featureloader.jsdoc (@probins)
- #3593 - Add /examples/index.js to .gitignore (@fredj)
- #3592 - Remove reference to binding in Collection docs (@probins)
- #3591 - Only draw the layer if visible and inside the resolution range (@fredj)
- #3528 - Fix memory leak when removing layers from ol.layer.Group (@fredj)
- #3549 - Move ol.*_DURATION const to a constructor option (@fredj)
- #3587 - Handle left/right segment intersections for top/bottom spans. (@tschaub)
- #3516 - Remove ol.format.BinaryFeature. (@tschaub)
- #3586 - Simplify dragAndDropInteraction in examples. (@probins)
- #3555 - Esri JSON support (@bartvde)
- #3583 - Add a one sentence summary for ol.proj.* and ol.layer.* exportable symbols (@marcjansen)
- #3581 - Always show links to related API documentation. (@tschaub)
- #3582 - Index what the examples require. (@tschaub)
- #3580 - Add a one sentence summary for ol.source.* exportable symbols (@marcjansen)
- #3551 - Automatically add links to API-docs in examples (@marcjansen)
- #3575 - Check proj equivalence by code. (@nd0ut)
- #3579 - Use HTTPS were available. (@tschaub)
- #3558 - Example sources in examples dir and built examples in build/examples. (@tschaub)
- #3550 - Reduce differences between the rendering test runner and the standard test runner. (@tschaub)
- #3576 - Add KML options related note the upgrade notes (@elemoine)
- #3573 - Modify draw interaction dispatch order (@gberaudo)
- #3572 - Do not return a null tileSize (@ahocevar)
- #3570 - Add missing @api (@gberaudo)
- #3569 - Fix link to Bootstrap documentation (@fredj)
- #3559 - Add support for non-square tiles (@ahocevar)
- #3568 - Move extractStyles option to ol.format.KML (@fredj)
- #3562 - Simplify .ol-zoomslider and .ol-overviewmap CSS (@fredj)
- #3565 - Move extractStyles option to ol.format.KML (@fredj)
- #3523 - Update proj4 version to 2.3.6 (@fredj)
- #3556 - Minor TileUTFGrid error fix (@klokantech)
- #3557 - Update FastClick externs to version 1.0.6 (@fredj)
- #3517 - Add tests for previously untested classes (@marcjansen)
- #3548 - Write the error stack instead of the error itself. (@tschaub)
- #3542 - Generate example index and rebuild examples on source changes. (@tschaub)
- #3530 - external resources not correctly in inline source of example (@bartvde)
- #3448 - Fix WebGL image layer rendering on retina displays (@elemoine)
- #3544 - Update comments about remaining GeoJSON work. (@tschaub)
- #3531 - Fix PointerEventHandler exception with Overlay containing SVG and IE9 (@mantonovic)
- #3521 - Remove goog.isDefAndNotNull test on ol.layer.Group#getLayers result (@fredj)
- #3481 - Proposal for a simpler vector API (@elemoine)
- #3472 - Remove the experimental bindTo method from ol.Object. (@tschaub)
- #3505 - Add a Create Custom Builds tutorial (@elemoine)
- #3513 - Remove layerGroup.setLayers(null) test (@fredj)
- #3511 - Add goog.provide's (@elemoine)
- #3509 - Dispatch change event even when geometry is set to null (@pgiraud)
- #3510 - Use sinon.spy to ensure change event is dispatched (@pgiraud)
- #3504 - Rework build-examples.js task. (@tschaub)
- #3470 - Add rendering tests (@tsauerwein)
- #3413 - Add support for generic external modules with Browserify (@tsauerwein)
- #3503 - Use vector source instead of feature overlay in snap example. (@tschaub)
- #3495 - Initial basic project setup tutorial (@bjornharrtell)
- #3488 - Add docs for exportable symbols. (@tschaub)
- #3441 - Add a "Compile Application and OpenLayers Together" tutorial (@elemoine)
- #3499 - Update to closure-util 1.4.0 (@elemoine)
- #3494 - Mark VectorContext @api (@gberaudo)
- #3409 - AssertionError in WMTS.optionsFromCapabilities. (@bartvde)
- #3493 - Add image loading events to ol.source.ImageStatic (@tsauerwein)
- #3490 - Add .editorconfig and instructions on its use. (@tschaub)
- #3489 - Use an abstract base class instead of IVectorContext. (@gberaudo)
- #3483 - Clarify view.setRotation docs (@tsauerwein)
- #3485 - build.py graceful interrupt (@malaretv)
- #3484 - Make sure we copy the example css if it exists (@bartvde)
- #3462 - Remove ol.format.GMLBase from the API (@ahocevar)
- #3445 - Start a FAQ document. (@marcjansen)
- #3468 - Use the coveralls executable. (@marcjansen)
- #3415 - Stable Only unchecked by default. (@malaretv)
- #3420 - Unregister viewport size listener on setTarget(null) (@elemoine)
- #3456 - Updated menu on the JSDOC template (non-responsive) (@klokan)
- #3475 - Template examples (@openlayers)
- #3455 - Fix pre-loaded icons images for WebGL (@tsauerwein)
- #3473 - Add more tests for ol.coordinate. (@marcjansen)
- #3464 - Mark more of the API stable. (@tschaub)
- #3469 - Update README. (@malaretv)
- #3467 - Update the coveralls badge. (@openlayers)
- #3466 - Include coveralls code-coverage badge in README. (@marcjansen)
- #3457 - Integrate istanbul for test coverage (@marcjansen)
- #3446 - Add updateWhileInteracting to olx.layer.VectorOptions (@elemoine)
- #3438 - Parser documentation and XML readme (@gberaudo)
- #3449 - Fix assertion message (@gberaudo)
- #3440 - Add fromLonLat and toLonLat convenience functions (@ahocevar)
- #3423 - Parse extrude and altitude mode (@gberaudo)
- #3431 - Better typing (@fredj)
- #3436 - Mention readme.md files as help for contributors (@ahocevar)
- #3433 - Add missing goog.provide/goog.require ol.source.TileEvent (@fredj)
- #3422 - Fix Select behavior when multi is false (@elemoine)
- #3428 - Reorder assertions and variable declarations. (@marcjansen)
- #3414 - Add missing ol.style.AtlasManager goog.require (@fredj)
- #3429 - Adding missing provide for SelectFilterFunction (@pgiraud)
- #3426 - Add assertion messages for all assertion statements (@bartvde)
- #3425 - Fix typo in ol.js (@elemoine)
- #3424 - Remove
@api
annotation fromol.WEBGL_MAX_TEXTURE_SIZE
. (@tschaub) - #3419 - Remove describe.only (@elemoine)
- #3417 - ol.interaction.Snap extent fix (@fperucic)
- #3410 - Add ol.Object.unset() method (@gberaudo)
- #3402 - Add "filter" option to Select interaction (@elemoine)
- #3416 - Remove unnecessary typecasts in examples (@fredj)
- #3411 - Listen for a 'change:geometry' event (@fperucic)
- #3109 - Snap feature (@fperucic)
- #3407 - Add v3.4.0 empty section to upgrade notes (@bartvde)