From b9b4778d053ae758d4a836125af366d596c7d4de Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 27 Jan 2016 14:07:26 +0100 Subject: [PATCH 1/5] Properly detect feature on unmanaged layer for toggle selection --- src/ol/interaction/selectinteraction.js | 5 +-- src/ol/source/vectorsource.js | 10 ++++++ .../ol/interaction/selectinteraction.test.js | 32 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 628a6c1c80..93e604019d 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -322,7 +322,8 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { * @param {ol.layer.Layer} layer Layer. */ function(feature, layer) { - if (layer !== this.featureOverlay_) { + goog.asserts.assertInstanceof(feature, ol.Feature); + if (layer !== null) { if (add || toggle) { if (this.filter_(feature, layer) && !ol.array.includes(features.getArray(), feature) && @@ -331,7 +332,7 @@ ol.interaction.Select.handleEvent = function(mapBrowserEvent) { this.addFeatureLayerAssociation_(feature, layer); } } - } else { + } else if (this.featureOverlay_.getSource().hasFeature(feature)) { if (remove || toggle) { deselected.push(feature); this.removeFeatureLayerAssociation_(feature); diff --git a/src/ol/source/vectorsource.js b/src/ol/source/vectorsource.js index 9a3352726c..df58419883 100644 --- a/src/ol/source/vectorsource.js +++ b/src/ol/source/vectorsource.js @@ -739,6 +739,16 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) { }; +/** + * @param {ol.Feature} feature Feature. + * @return {boolean} Feature is in source. + */ +ol.source.Vector.prototype.hasFeature = function(feature) { + var id = feature.getId(); + return id ? id in this.idIndex_ : goog.getUid(feature) in this.undefIdIndex_; +}; + + /** * @return {boolean} Is empty. */ diff --git a/test/spec/ol/interaction/selectinteraction.test.js b/test/spec/ol/interaction/selectinteraction.test.js index 4feac188ac..e032b3f28c 100644 --- a/test/spec/ol/interaction/selectinteraction.test.js +++ b/test/spec/ol/interaction/selectinteraction.test.js @@ -158,6 +158,38 @@ describe('ol.interaction.Select', function() { }); }); + describe('toggle selecting polygons', function() { + var select; + + beforeEach(function() { + select = new ol.interaction.Select({ + multi: true + }); + map.addInteraction(select); + }); + + it('with SHIFT + single-click', function() { + var listenerSpy = sinon.spy(); + select.on('select', listenerSpy); + + simulateEvent(ol.MapBrowserEvent.EventType.SINGLECLICK, 10, -20, true); + + expect(listenerSpy.callCount).to.be(1); + + var features = select.getFeatures(); + expect(features.getLength()).to.equal(4); + + map.renderSync(); + + simulateEvent(ol.MapBrowserEvent.EventType.SINGLECLICK, 10, -20, true); + + expect(listenerSpy.callCount).to.be(2); + + features = select.getFeatures(); + expect(features.getLength()).to.equal(0); + }); + }); + describe('filter features using the filter option', function() { describe('with multi set to true', function() { From 04db1c3e4de7db2de36f0c9ab49cc5400b985552 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Mon, 1 Feb 2016 17:58:38 +0100 Subject: [PATCH 2/5] Expand urls before setting this.urls --- src/ol/source/urltilesource.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/source/urltilesource.js b/src/ol/source/urltilesource.js index c87c25be5e..36d410dcc6 100644 --- a/src/ol/source/urltilesource.js +++ b/src/ol/source/urltilesource.js @@ -182,9 +182,9 @@ ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction) { * @api stable */ ol.source.UrlTile.prototype.setUrl = function(url) { - this.urls = [url]; - var urls = ol.TileUrlFunction.expandUrl(url); - this.setTileUrlFunction(this.fixedTileUrlFunction || + var urls = this.urls = ol.TileUrlFunction.expandUrl(url); + this.setTileUrlFunction(this.fixedTileUrlFunction ? + this.fixedTileUrlFunction.bind(this) : ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid)); }; From a910ab626a096dc73cc034e4c3954a3b9fd63b21 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 3 Feb 2016 12:44:48 +0100 Subject: [PATCH 3/5] Add test for URL template expansion --- test/spec/ol/source/urltilesource.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/spec/ol/source/urltilesource.test.js b/test/spec/ol/source/urltilesource.test.js index 8273b5956a..f59f425aa9 100644 --- a/test/spec/ol/source/urltilesource.test.js +++ b/test/spec/ol/source/urltilesource.test.js @@ -3,6 +3,17 @@ goog.provide('ol.test.source.UrlTile'); describe('ol.source.UrlTile', function() { + describe('url option', function() { + it('expands url template', function() { + var tileSource = new ol.source.UrlTile({ + url: '{1-3}' + }); + + var urls = tileSource.getUrls(); + expect(urls).to.eql(['1', '2', '3']); + }); + }); + describe('tileUrlFunction', function() { var tileSource, tileGrid; From edb4f233b0706d91e46744694240e3b79c9fb3cd Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 3 Feb 2016 17:03:28 +0100 Subject: [PATCH 4/5] Changelog for v3.13.1 --- changelog/v3.13.1.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 changelog/v3.13.1.md diff --git a/changelog/v3.13.1.md b/changelog/v3.13.1.md new file mode 100644 index 0000000000..f292ba23c0 --- /dev/null +++ b/changelog/v3.13.1.md @@ -0,0 +1,10 @@ +# v3.13.1 + +## Summary + +The v3.13.1 release is a patch release that addresses a few regressions in the v3.13.0 release. See the [v3.13.0 release notes](https://github.com/openlayers/ol3/releases/tag/v3.13.0) for details on upgrading from v3.12. + +## Fixes + + * [#4736](https://github.com/openlayers/ol3/pull/4736) - Properly detect feature on unmanaged layer for toggle selection ([@ahocevar](https://github.com/ahocevar)) + * [#4777](https://github.com/openlayers/ol3/pull/4777) - Fix source.UrlTile URL expansion ([@gberaudo](https://github.com/gberaudo)) From f73dbc513b9a8c0730fadaa39195613bd646b05a Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 3 Feb 2016 17:04:10 +0100 Subject: [PATCH 5/5] Update package version to 3.13.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75b79d00af..64fca50626 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openlayers", - "version": "3.13.0", + "version": "3.13.1", "description": "Build tools and sources for developing OpenLayers based mapping applications", "keywords": [ "map",