Add wrapX option for ol.source.WMTS
This commit is contained in:
@@ -2,7 +2,6 @@ goog.require('ol.Map');
|
|||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
goog.require('ol.format.WMTSCapabilities');
|
goog.require('ol.format.WMTSCapabilities');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.WMTS');
|
goog.require('ol.source.WMTS');
|
||||||
|
|
||||||
@@ -14,8 +13,6 @@ $.ajax('data/WMTSCapabilities.xml').then(function(response) {
|
|||||||
var options = ol.source.WMTS.optionsFromCapabilities(result,
|
var options = ol.source.WMTS.optionsFromCapabilities(result,
|
||||||
{layer: 'layer-7328', matrixSet: 'EPSG:3857'});
|
{layer: 'layer-7328', matrixSet: 'EPSG:3857'});
|
||||||
|
|
||||||
var projection = ol.proj.get('EPSG:3857');
|
|
||||||
var projectionExtent = projection.getExtent();
|
|
||||||
map = new ol.Map({
|
map = new ol.Map({
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
@@ -24,7 +21,6 @@ $.ajax('data/WMTSCapabilities.xml').then(function(response) {
|
|||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
extent: projectionExtent,
|
|
||||||
source: new ol.source.WMTS(options)
|
source: new ol.source.WMTS(options)
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
+2
-2
@@ -35,7 +35,6 @@ var map = new ol.Map({
|
|||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
opacity: 0.7,
|
opacity: 0.7,
|
||||||
extent: projectionExtent,
|
|
||||||
source: new ol.source.WMTS({
|
source: new ol.source.WMTS({
|
||||||
attributions: [attribution],
|
attributions: [attribution],
|
||||||
url: 'http://services.arcgisonline.com/arcgis/rest/' +
|
url: 'http://services.arcgisonline.com/arcgis/rest/' +
|
||||||
@@ -49,7 +48,8 @@ var map = new ol.Map({
|
|||||||
resolutions: resolutions,
|
resolutions: resolutions,
|
||||||
matrixIds: matrixIds
|
matrixIds: matrixIds
|
||||||
}),
|
}),
|
||||||
style: 'default'
|
style: 'default',
|
||||||
|
wrapX: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|||||||
+10
-1
@@ -5530,7 +5530,8 @@ olx.source.StaticVectorOptions.prototype.urls;
|
|||||||
* urls: (Array.<string>|undefined),
|
* urls: (Array.<string>|undefined),
|
||||||
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
|
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
|
||||||
* ol.TileState, string, ?string,
|
* ol.TileState, string, ?string,
|
||||||
* ol.TileLoadFunctionType)|undefined)}}
|
* ol.TileLoadFunctionType)|undefined),
|
||||||
|
* wrapX: (boolean|undefined)}}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.source.WMTSOptions;
|
olx.source.WMTSOptions;
|
||||||
@@ -5689,6 +5690,14 @@ olx.source.WMTSOptions.prototype.tileLoadFunction;
|
|||||||
olx.source.WMTSOptions.prototype.urls;
|
olx.source.WMTSOptions.prototype.urls;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to wrap the world horizontally. Default is `false`.
|
||||||
|
* @type {boolean|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.source.WMTSOptions.prototype.wrapX;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
|
||||||
* crossOrigin: (null|string|undefined),
|
* crossOrigin: (null|string|undefined),
|
||||||
|
|||||||
+12
-15
@@ -3,7 +3,6 @@ goog.provide('ol.source.WMTSRequestEncoding');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.math');
|
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('goog.string');
|
goog.require('goog.string');
|
||||||
goog.require('goog.uri.utils');
|
goog.require('goog.uri.utils');
|
||||||
@@ -170,7 +169,6 @@ ol.source.WMTS = function(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tmpExtent = ol.extent.createEmpty();
|
var tmpExtent = ol.extent.createEmpty();
|
||||||
var tmpTileCoord = [0, 0, 0];
|
|
||||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
@@ -188,16 +186,6 @@ ol.source.WMTS = function(options) {
|
|||||||
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, tmpExtent);
|
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, tmpExtent);
|
||||||
var extent = projection.getExtent();
|
var extent = projection.getExtent();
|
||||||
|
|
||||||
if (!goog.isNull(extent) && projection.isGlobal()) {
|
|
||||||
var numCols = Math.ceil(
|
|
||||||
ol.extent.getWidth(extent) /
|
|
||||||
ol.extent.getWidth(tileExtent));
|
|
||||||
x = goog.math.modulo(x, numCols);
|
|
||||||
tmpTileCoord[0] = tileCoord[0];
|
|
||||||
tmpTileCoord[1] = x;
|
|
||||||
tmpTileCoord[2] = tileCoord[2];
|
|
||||||
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
|
|
||||||
}
|
|
||||||
if (!ol.extent.intersects(tileExtent, extent) ||
|
if (!ol.extent.intersects(tileExtent, extent) ||
|
||||||
ol.extent.touches(tileExtent, extent)) {
|
ol.extent.touches(tileExtent, extent)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -215,7 +203,8 @@ ol.source.WMTS = function(options) {
|
|||||||
tileGrid: tileGrid,
|
tileGrid: tileGrid,
|
||||||
tileLoadFunction: options.tileLoadFunction,
|
tileLoadFunction: options.tileLoadFunction,
|
||||||
tilePixelRatio: options.tilePixelRatio,
|
tilePixelRatio: options.tilePixelRatio,
|
||||||
tileUrlFunction: tileUrlFunction
|
tileUrlFunction: tileUrlFunction,
|
||||||
|
wrapX: goog.isDef(options.wrapX) ? options.wrapX : false
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -348,7 +337,7 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
goog.asserts.assert(!goog.isNull(l));
|
goog.asserts.assert(!goog.isNull(l));
|
||||||
|
|
||||||
goog.asserts.assert(l['TileMatrixSetLink'].length > 0);
|
goog.asserts.assert(l['TileMatrixSetLink'].length > 0);
|
||||||
var idx, matrixSet;
|
var idx, matrixSet, wrapX;
|
||||||
if (l['TileMatrixSetLink'].length > 1) {
|
if (l['TileMatrixSetLink'].length > 1) {
|
||||||
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
idx = goog.array.findIndex(l['TileMatrixSetLink'],
|
||||||
function(elt, index, array) {
|
function(elt, index, array) {
|
||||||
@@ -372,6 +361,13 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
|
|
||||||
goog.asserts.assert(!goog.isNull(matrixSet));
|
goog.asserts.assert(!goog.isNull(matrixSet));
|
||||||
|
|
||||||
|
var wgs84BoundingBox = l['WGS84BoundingBox'];
|
||||||
|
if (goog.isDef(wgs84BoundingBox)) {
|
||||||
|
var wgs84ProjectionExtent = ol.proj.get('EPSG:4326').getExtent();
|
||||||
|
wrapX = (wgs84BoundingBox[0] == wgs84ProjectionExtent[0] &&
|
||||||
|
wgs84BoundingBox[2] == wgs84ProjectionExtent[2]);
|
||||||
|
}
|
||||||
|
|
||||||
var format = /** @type {string} */ (l['Format'][0]);
|
var format = /** @type {string} */ (l['Format'][0]);
|
||||||
if (goog.isDef(config['format'])) {
|
if (goog.isDef(config['format'])) {
|
||||||
format = config['format'];
|
format = config['format'];
|
||||||
@@ -463,7 +459,8 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
|
|||||||
requestEncoding: requestEncoding,
|
requestEncoding: requestEncoding,
|
||||||
tileGrid: tileGrid,
|
tileGrid: tileGrid,
|
||||||
style: style,
|
style: style,
|
||||||
dimensions: dimensions
|
dimensions: dimensions,
|
||||||
|
wrapX: wrapX
|
||||||
};
|
};
|
||||||
|
|
||||||
/* jshint +W069 */
|
/* jshint +W069 */
|
||||||
|
|||||||
Reference in New Issue
Block a user