Pass pixelRatio to canvasFunction
This commit is contained in:
4
examples/d3.js
vendored
4
examples/d3.js
vendored
@@ -38,11 +38,13 @@ d3.json('data/us.json', function(error, us) {
|
|||||||
* This function uses d3 to render the topojson features to a canvas.
|
* This function uses d3 to render the topojson features to a canvas.
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.Size} size Size.
|
* @param {ol.Size} size Size.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
* @return {HTMLCanvasElement}
|
* @return {HTMLCanvasElement}
|
||||||
*/
|
*/
|
||||||
var canvasFunction = function(extent, resolution, size, projection) {
|
var canvasFunction = function(extent, resolution, pixelRatio,
|
||||||
|
size, projection) {
|
||||||
var canvasWidth = size[0];
|
var canvasWidth = size[0];
|
||||||
var canvasHeight = size[1];
|
var canvasHeight = size[1];
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ goog.provide('ol.CanvasFunctionType');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {function(this:ol.source.ImageCanvas, ol.Extent, number, ol.Size,
|
* @typedef {function(this:ol.source.ImageCanvas, ol.Extent, number,
|
||||||
* ol.proj.Projection): HTMLCanvasElement}
|
* number, ol.Size, ol.proj.Projection): HTMLCanvasElement}
|
||||||
*/
|
*/
|
||||||
ol.CanvasFunctionType;
|
ol.CanvasFunctionType;
|
||||||
|
|||||||
@@ -65,12 +65,13 @@ ol.source.ImageCanvas.prototype.getImage =
|
|||||||
var height = (extent[3] - extent[1]) / resolution;
|
var height = (extent[3] - extent[1]) / resolution;
|
||||||
var size = [width * pixelRatio, height * pixelRatio];
|
var size = [width * pixelRatio, height * pixelRatio];
|
||||||
|
|
||||||
var canvasElement = this.canvasFunction_(extent, resolution, size,
|
var canvasElement = this.canvasFunction_(
|
||||||
projection);
|
extent, resolution, pixelRatio, size, projection);
|
||||||
canvas = new ol.ImageCanvas(extent, resolution, pixelRatio,
|
if (!goog.isNull(canvasElement)) {
|
||||||
this.getAttributions(), canvasElement);
|
canvas = new ol.ImageCanvas(extent, resolution, pixelRatio,
|
||||||
|
this.getAttributions(), canvasElement);
|
||||||
|
}
|
||||||
this.canvas_ = canvas;
|
this.canvas_ = canvas;
|
||||||
|
|
||||||
return canvas;
|
return canvas;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user