Take pixel ratio into account in layer-spy example
This commit is contained in:
@@ -48,12 +48,14 @@ $(map.getViewport()).on('mousemove', function(evt) {
|
|||||||
// before rendering the layer, do some clipping
|
// before rendering the layer, do some clipping
|
||||||
imagery.on('precompose', function(event) {
|
imagery.on('precompose', function(event) {
|
||||||
var ctx = event.context;
|
var ctx = event.context;
|
||||||
|
var pixelRatio = event.frameState.pixelRatio;
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
if (mousePosition) {
|
if (mousePosition) {
|
||||||
// only show a circle around the mouse
|
// only show a circle around the mouse
|
||||||
ctx.arc(mousePosition[0], mousePosition[1], radius, 0, 2 * Math.PI);
|
ctx.arc(mousePosition[0] * pixelRatio, mousePosition[1] * pixelRatio,
|
||||||
ctx.lineWidth = 5;
|
radius * pixelRatio, 0, 2 * Math.PI);
|
||||||
|
ctx.lineWidth = 5 * pixelRatio;
|
||||||
ctx.strokeStyle = 'rgba(0,0,0,0.5)';
|
ctx.strokeStyle = 'rgba(0,0,0,0.5)';
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user