Permalink
Browse files

Only adjust tile when necessary

  • Loading branch information...
1 parent bdd8a75 commit 5b36cf13127c5deb3c878cadd47d5c533387e541 @tschaub tschaub committed Sep 26, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/ol/renderer/dom/tilelayer.js
@@ -164,6 +164,7 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
}
var mapExtent = /** @type {!ol.Extent} */ map.getExtent();
var mapResolution = /** @type {number} */ map.getResolution();
+ var resolutionChanged = (mapResolution !== this.renderedMapResolution_);
var tileLayer = this.getLayer();
var tileStore = tileLayer.getStore();
@@ -264,11 +265,14 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
var style = img.style;
// TODO: use translate method
// TODO: only set this when changed (z change)
- style.left = (pixelBounds.minX - tileOffset.x) + 'px';
- style.top = (-pixelBounds.maxY - tileOffset.y) + 'px';
- style.width = pixelBounds.getWidth() + 'px';
- style.height = pixelBounds.getHeight() + 'px';
- if (!(key in this.renderedTiles_)) {
+ var append = !(key in this.renderedTiles_);
+ if (append || resolutionChanged) {
+ style.left = (pixelBounds.minX - tileOffset.x) + 'px';
+ style.top = (-pixelBounds.maxY - tileOffset.y) + 'px';
+ style.width = pixelBounds.getWidth() + 'px';
+ style.height = pixelBounds.getHeight() + 'px';
+ }
+ if (append) {
this.renderedTiles_[key] = tile;
style.position = 'absolute';
if (tileZ === z) {

0 comments on commit 5b36cf1

Please sign in to comment.