Support tile sources without configured projection
This change adds a lot of flexibility to working with tile layers: Sources where the server projection or tile grid do not matter can now be constructed without specifying a projection or tile grid. The tileUrlFunction/imageUrlFunction now also creates updated URLs when the params of the layer change, so things like mergeNewParams in ol2 will be possible. A nice side effect of this whole change is that there is no more duplicated code between tiled and single image WMS layers. While I was at it, I also fixed a WMS 1.1.1 axis order issue and incorrect STYLES params (STYLES=& instead of STYLES&).
This commit is contained in:
@@ -258,3 +258,20 @@ ol.renderer.Layer.prototype.updateWantedTiles =
|
||||
}
|
||||
wantedTiles[tileSourceKey][coordKey] = true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {function(ol.Tile): boolean} isLoadedFunction Function to
|
||||
* determine if the tile is loaded.
|
||||
* @param {ol.source.TileSource} tileSource Tile source.
|
||||
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
|
||||
* @param {ol.Projection} projection Projection.
|
||||
* @return {function(ol.TileCoord): ol.Tile} Returns a tile if it is loaded.
|
||||
*/
|
||||
ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
|
||||
function(isLoadedFunction, tileSource, tileGrid, projection) {
|
||||
return function(tileCoord) {
|
||||
var tile = tileSource.getTile(tileCoord, tileGrid, projection);
|
||||
return isLoadedFunction(tile) ? tile : null;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user