Take pixel ratio into account in layer-spy example

This commit is contained in:
Tom Payne
2014-03-23 02:54:15 +01:00
parent 56e958f209
commit f051230f99

View File

@@ -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();
}