Skip to content

Commit

Permalink
Merge pull request #1265 from OpenGeoscience/array-forwarded-features
Browse files Browse the repository at this point in the history
fix: When binding an array of events, don't duplicate
  • Loading branch information
manthey authored Mar 28, 2023
2 parents 3447174 + fd08bdb commit 3965f12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pixelmapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ var pixelmapLayer = function (arg) {
['modified', 'geoOn', 'geoOff', 'geoOnce'].forEach((funcName) => {
const superFunc = m_this[funcName];
m_this[funcName] = function () {
m_pixelmapFeature[funcName].apply(this, arguments);
if (!Array.isArray(arguments[0])) {
m_pixelmapFeature[funcName].apply(this, arguments);
}
return superFunc.apply(this, arguments);
};
});
Expand Down
19 changes: 19 additions & 0 deletions tests/gl-cases/pixelmapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ describe('webglPixelmapLayer', function () {
done();
});
});
it('geoOn and geoOff from array', function (done) {
createPixelmap();
var click = 0;
layer.geoOn([geo.event.feature.mouseclick], () => {
click += 1;
});
// wait for the tiles to be available
map.onIdle(() => {
expect(click).toEqual(0);
map.interactor().simulateEvent('mousedown', {map: {x: 390, y: 200}});
map.interactor().simulateEvent('mouseup', {map: {x: 390, y: 200}});
expect(click).toEqual(1);
layer.geoOff([geo.event.feature.mouseclick]);
map.interactor().simulateEvent('mousedown', {map: {x: 390, y: 200}});
map.interactor().simulateEvent('mouseup', {map: {x: 390, y: 200}});
expect(click).toEqual(1);
done();
});
});
it('geospatial', function (done) {
map = geo.map({node: '#map'});
layer = map.createLayer('pixelmap', {
Expand Down

0 comments on commit 3965f12

Please sign in to comment.