Merge pull request #5044 from fblackburn/snapinteraction

Snap interaction now handle feature without geometry properly
This commit is contained in:
Andreas Hocevar
2016-04-27 14:25:17 +02:00
2 changed files with 46 additions and 19 deletions

View File

@@ -100,6 +100,26 @@ describe('ol.interaction.Snap', function() {
expect(event.coordinate).to.eql([10, 0]);
});
it('handle feature without geometry', function() {
var feature = new ol.Feature();
var snapInteraction = new ol.interaction.Snap({
features: new ol.Collection([feature]),
pixelTolerance: 5,
edge: false
});
snapInteraction.setMap(map);
feature.setGeometry(new ol.geom.LineString([[-10, 0], [10, 0]]));
var event = {
pixel: [7 + width / 2, height / 2 - 4],
coorinate: [7, 4],
map: map
};
ol.interaction.Snap.handleEvent_.call(snapInteraction, event);
expect(event.coordinate).to.eql([10, 0]);
});
});
});