From 00275f1a67bcc5389d4aa1c0b61c5f6fea322f26 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 20 Feb 2020 15:25:32 +0000 Subject: [PATCH] Draw labels in a postrender function --- test/spec/ol/graticule.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/spec/ol/graticule.test.js b/test/spec/ol/graticule.test.js index 78533e8136..c3e9ed0499 100644 --- a/test/spec/ol/graticule.test.js +++ b/test/spec/ol/graticule.test.js @@ -46,7 +46,21 @@ describe('ol.layer.Graticule', function() { const squaredTolerance = resolution * resolution / 4.0; graticule.updateProjectionInfo_(projection); graticule.createGraticule_(extent, [0, 0], resolution, squaredTolerance); - graticule.drawLabels_({frameState: {extent: extent, viewState: {rotation: 0}}}); + const event = { + context: document.createElement('canvas').getContext('2d'), + inversePixelTransform: [1, 0, 0, 1, 0, 0], + frameState: { + coordinateToPixelTransform: [1, 0, 0, 1, 0, 0], + extent: extent, + pixelRatio: 1, + viewState: { + projection: projection, + resolution: resolution, + rotation: 0 + } + } + }; + graticule.drawLabels_(event); expect(graticule.meridiansLabels_.length).to.be(13); expect(graticule.meridiansLabels_[0].text).to.be('0° 00′ 00″'); expect(graticule.meridiansLabels_[0].geom.getCoordinates()[0]).to.roughlyEqual(0, 1e-9);