Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Decoupling canvas tile grid from vector source grid

If we have a gridded vector source, the grid should have something to do with the source data (e.g. the vector data is available in a regular grid).  The vector layer renderer's internal grid is for rendering canvas tiles and doesn't have anything to do with the source.
  • Loading branch information...
commit ce4b95f96073ad193ecb4bea2c499147ccc8ae28 1 parent e9fb83d
Tim Schaub tschaub authored
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/ol/renderer/canvas/canvasvectorlayerrenderer.js
16 src/ol/renderer/canvas/canvasvectorlayerrenderer.js
View
@@ -145,6 +145,15 @@ ol.renderer.canvas.VectorLayer = function(mapRenderer, layer) {
*/
this.pendingCachePrune_ = false;
+ /**
+ * Grid used for internal generation of canvas tiles. This is created
+ * lazily so we have access to the view projection.
+ *
+ * @private
+ * @type {ol.TileGrid}
+ */
+ this.tileGrid_ = null;
+
};
goog.inherits(ol.renderer.canvas.VectorLayer, ol.renderer.canvas.Layer);
@@ -186,14 +195,15 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
resolution = view2DState.resolution,
extent = frameState.extent,
source = this.getVectorLayer().getVectorSource(),
- tileGrid = source.getTileGrid();
+ tileGrid = this.tileGrid_;
if (goog.isNull(tileGrid)) {
// lazy tile source creation to match the view projection
tileGrid = ol.tilegrid.createForProjection(
- view2DState.projection, /** TODO: get this elsewhere */ 22,
+ view2DState.projection,
+ 22, // should be no harm in going big here - ideally, it would be ∞
new ol.Size(512, 512));
- source.setTileGrid(tileGrid);
+ this.tileGrid_ = tileGrid;
}
// set up transform for the layer canvas to be drawn to the map canvas
Please sign in to comment.
Something went wrong with that request. Please try again.