From f051230f99d1af39f3b8fb930010f276ab013d01 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 23 Mar 2014 02:54:15 +0100 Subject: [PATCH] Take pixel ratio into account in layer-spy example --- examples/layer-spy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/layer-spy.js b/examples/layer-spy.js index 69986b15f0..5cf5bbcccb 100644 --- a/examples/layer-spy.js +++ b/examples/layer-spy.js @@ -48,12 +48,14 @@ $(map.getViewport()).on('mousemove', function(evt) { // before rendering the layer, do some clipping imagery.on('precompose', function(event) { var ctx = event.context; + var pixelRatio = event.frameState.pixelRatio; ctx.save(); ctx.beginPath(); if (mousePosition) { // only show a circle around the mouse - ctx.arc(mousePosition[0], mousePosition[1], radius, 0, 2 * Math.PI); - ctx.lineWidth = 5; + ctx.arc(mousePosition[0] * pixelRatio, mousePosition[1] * pixelRatio, + radius * pixelRatio, 0, 2 * Math.PI); + ctx.lineWidth = 5 * pixelRatio; ctx.strokeStyle = 'rgba(0,0,0,0.5)'; ctx.stroke(); }