Skip to content

Commit

Permalink
Merge pull request #927 from OpenGeoscience/canvas-camera-viewport
Browse files Browse the repository at this point in the history
Don't use camera._viewport in canvas renderer.
  • Loading branch information
manthey authored Sep 11, 2018
2 parents c681b2f + b82ebd8 commit b567b30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/canvas/canvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ var canvasRenderer = function (arg) {
this._renderFrame = function () {
var layer = m_this.layer(),
map = layer.map(),
camera = map.camera(),
viewport = camera._viewport,
mapSize = map.size(),
features = layer.features(),
i;

Expand All @@ -129,7 +128,7 @@ var canvasRenderer = function (arg) {
// Clear the canvas.
if (m_clearCanvas) {
m_this.context2d.setTransform(1, 0, 0, 1, 0, 0);
m_this.context2d.clearRect(0, 0, viewport.width, viewport.height);
m_this.context2d.clearRect(0, 0, mapSize.width, mapSize.height);
}

for (i = 0; i < features.length; i += 1) {
Expand Down
14 changes: 7 additions & 7 deletions src/canvas/heatmapFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ var canvas_heatmapFeature = function (arg) {
intensityFunc = m_this.intensity(),
minIntensity = m_this.minIntensity(),
rangeIntensity = (m_this.maxIntensity() - minIntensity) || 1,
viewport = map.camera()._viewport,
mapSize = map.size(),
bins = [],
rw = Math.ceil(radius / binSize),
maxx = Math.ceil(viewport.width / binSize) + rw * 2 + 2,
maxy = Math.ceil(viewport.height / binSize) + rw * 2 + 2,
maxx = Math.ceil(mapSize.width / binSize) + rw * 2 + 2,
maxy = Math.ceil(mapSize.height / binSize) + rw * 2 + 2,
datalen = data.length,
idx, pos, intensity, x, y, binrow, offsetx, offsety;

Expand Down Expand Up @@ -303,14 +303,14 @@ var canvas_heatmapFeature = function (arg) {
binned = m_this.binned(),
canvas, pixelArray,
layer = m_this.layer(),
viewport = map.camera()._viewport;
mapSize = map.size();

/* Determine if we should bin the data */
if (binned === true || binned === 'auto') {
binned = Math.max(Math.floor(radius / 8), 3);
if (m_this.binned() === 'auto') {
var numbins = (Math.ceil((viewport.width + radius * 2) / binned) *
Math.ceil((viewport.height + radius * 2) / binned));
var numbins = (Math.ceil((mapSize.width + radius * 2) / binned) *
Math.ceil((mapSize.height + radius * 2) / binned));
if (numbins >= data.length) {
binned = 0;
}
Expand All @@ -323,7 +323,7 @@ var canvas_heatmapFeature = function (arg) {
m_this._binned = binned;

context2d.setTransform(1, 0, 0, 1, 0, 0);
context2d.clearRect(0, 0, viewport.width, viewport.height);
context2d.clearRect(0, 0, mapSize.width, mapSize.height);
m_heatMapTransform = '';
map.scheduleAnimationFrame(m_this._setTransform, false);
layer.canvas().css({transform: ''});
Expand Down

0 comments on commit b567b30

Please sign in to comment.