Render map replay group on the correct world instead of wrapping it

By using the frameState's focus, we can adjust extent and transform and
render it for the world of interest instead of wrapping it and rendering
for every visible world.
This commit is contained in:
Andreas Hocevar
2015-04-22 09:11:19 +02:00
parent 23ed120361
commit 513677fecd
7 changed files with 108 additions and 101 deletions

View File

@@ -24,7 +24,8 @@ ol.source.State = {
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* logo: (string|olx.LogoOptions|undefined),
* projection: ol.proj.ProjectionLike,
* state: (ol.source.State|undefined)}}
* state: (ol.source.State|undefined),
* wrapX: (boolean|undefined)}}
*/
ol.source.SourceOptions;
@@ -72,6 +73,12 @@ ol.source.Source = function(options) {
this.state_ = goog.isDef(options.state) ?
options.state : ol.source.State.READY;
/**
* @private
* @type {boolean|undefined}
*/
this.wrapX_ = options.wrapX;
};
goog.inherits(ol.source.Source, ol.Object);
@@ -135,6 +142,14 @@ ol.source.Source.prototype.getState = function() {
};
/**
* @return {boolean|undefined} Wrap X.
*/
ol.source.Source.prototype.getWrapX = function() {
return this.wrapX_;
};
/**
* Set the attributions of the source.
* @param {Array.<ol.Attribution>} attributions Attributions.

View File

@@ -47,7 +47,8 @@ ol.source.Tile = function(options) {
extent: options.extent,
logo: options.logo,
projection: options.projection,
state: options.state
state: options.state,
wrapX: options.wrapX
});
/**
@@ -81,12 +82,6 @@ ol.source.Tile = function(options) {
*/
this.tmpSize = [0, 0];
/**
* @private
* @type {boolean|undefined}
*/
this.wrapX_ = options.wrapX;
};
goog.inherits(ol.source.Tile, ol.source.Source);
@@ -221,10 +216,10 @@ ol.source.Tile.prototype.getTilePixelSize =
/**
* Handles x-axis wrapping. When `this.wrapX_` is undefined or the projection
* is not a global projection, `tileCoord` will be returned unaltered. When
* `this.wrapX_` is true, the tile coordinate will be wrapped horizontally.
* When `this.wrapX_` is `false`, `null` will be returned for tiles that are
* Handles x-axis wrapping. When `wrapX` is `undefined` or the projection is not
* a global projection, `tileCoord` will be returned unaltered. When `wrapX` is
* `true`, the tile coordinate will be wrapped horizontally.
* When `wrapX` is `false`, `null` will be returned for tiles that are
* outside the projection extent.
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.proj.Projection=} opt_projection Projection.
@@ -235,8 +230,9 @@ ol.source.Tile.prototype.getWrapXTileCoord =
var projection = goog.isDef(opt_projection) ?
opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection);
if (goog.isDef(this.wrapX_) && tileGrid.isGlobal(tileCoord[0], projection)) {
return this.wrapX_ ?
var wrapX = this.getWrapX();
if (goog.isDef(wrapX) && tileGrid.isGlobal(tileCoord[0], projection)) {
return wrapX ?
ol.tilecoord.wrapX(tileCoord, tileGrid, projection) :
ol.tilecoord.clipX(tileCoord, tileGrid, projection);
} else {

View File

@@ -79,7 +79,8 @@ ol.source.Vector = function(opt_options) {
attributions: options.attributions,
logo: options.logo,
projection: undefined,
state: ol.source.State.READY
state: ol.source.State.READY,
wrapX: goog.isDef(options.wrapX) ? options.wrapX : true
});
/**
@@ -146,12 +147,6 @@ ol.source.Vector = function(opt_options) {
this.addFeaturesInternal(options.features);
}
/**
* @type {boolean}
* @private
*/
this.wrapX_ = goog.isDef(options.wrapX) ? options.wrapX : true;
};
goog.inherits(ol.source.Vector, ol.source.Source);
@@ -570,14 +565,6 @@ ol.source.Vector.prototype.getFeatureById = function(id) {
};
/**
* @return {boolean}
*/
ol.source.Vector.prototype.getWrapX = function() {
return this.wrapX_;
};
/**
* @param {goog.events.Event} event Event.
* @private