Merge pull request #3145 from elemoine/wrapx

Add wrapX option to source.OSM and source.BingMaps
This commit is contained in:
Éric Lemoine
2015-01-16 17:40:13 +01:00
3 changed files with 30 additions and 4 deletions
+21 -2
View File
@@ -3393,7 +3393,8 @@ olx.source;
* key: string, * key: string,
* imagerySet: string, * imagerySet: string,
* maxZoom: (number|undefined), * maxZoom: (number|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined)}} * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* wrapX: (boolean|undefined)}}
* @api * @api
*/ */
olx.source.BingMapsOptions; olx.source.BingMapsOptions;
@@ -3439,6 +3440,15 @@ olx.source.BingMapsOptions.prototype.maxZoom;
*/ */
olx.source.BingMapsOptions.prototype.tileLoadFunction; olx.source.BingMapsOptions.prototype.tileLoadFunction;
/**
* Whether to wrap the world horizontally. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.source.BingMapsOptions.prototype.wrapX;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* distance: (number|undefined), * distance: (number|undefined),
@@ -4304,7 +4314,8 @@ olx.source.TileDebugOptions.prototype.tileGrid;
* crossOrigin: (null|string|undefined), * crossOrigin: (null|string|undefined),
* maxZoom: (number|undefined), * maxZoom: (number|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined), * tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* url: (string|undefined)}} * url: (string|undefined),
* wrapX: (boolean|undefined)}}
* @api * @api
*/ */
olx.source.OSMOptions; olx.source.OSMOptions;
@@ -4357,6 +4368,14 @@ olx.source.OSMOptions.prototype.tileLoadFunction;
olx.source.OSMOptions.prototype.url; olx.source.OSMOptions.prototype.url;
/**
* Whether to wrap the world horizontally. Default is `true`.
* @type {boolean|undefined}
* @api
*/
olx.source.OSMOptions.prototype.wrapX;
/** /**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined), * @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* doc: (Document|undefined), * doc: (Document|undefined),
+7 -1
View File
@@ -48,6 +48,12 @@ ol.source.BingMaps = function(options) {
*/ */
this.maxZoom_ = goog.isDef(options.maxZoom) ? options.maxZoom : -1; this.maxZoom_ = goog.isDef(options.maxZoom) ? options.maxZoom : -1;
/**
* @private
* @type {boolean}
*/
this.wrapX_ = goog.isDef(options.wrapX) ? options.wrapX : true;
var protocol = ol.IS_HTTPS ? 'https:' : 'http:'; var protocol = ol.IS_HTTPS ? 'https:' : 'http:';
var uri = new goog.Uri( var uri = new goog.Uri(
protocol + '//dev.virtualearth.net/REST/v1/Imagery/Metadata/' + protocol + '//dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
@@ -108,7 +114,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
var culture = this.culture_; var culture = this.culture_;
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform( this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
tileGrid.createTileCoordTransform(), tileGrid.createTileCoordTransform({wrapX: this.wrapX_}),
ol.TileUrlFunction.createFromTileUrlFunctions( ol.TileUrlFunction.createFromTileUrlFunctions(
goog.array.map( goog.array.map(
resource.imageUrlSubdomains, resource.imageUrlSubdomains,
+2 -1
View File
@@ -39,7 +39,8 @@ ol.source.OSM = function(opt_options) {
opaque: true, opaque: true,
maxZoom: goog.isDef(options.maxZoom) ? options.maxZoom : 19, maxZoom: goog.isDef(options.maxZoom) ? options.maxZoom : 19,
tileLoadFunction: options.tileLoadFunction, tileLoadFunction: options.tileLoadFunction,
url: url url: url,
wrapX: options.wrapX
}); });
}; };