From 9a4aed3d7c46d48683e8fc6cd7a7c0fb00a1c820 Mon Sep 17 00:00:00 2001 From: Florent gravin Date: Wed, 28 Mar 2018 17:14:31 +0200 Subject: [PATCH] Remove olx.source.VectorTileOptions --- externs/olx.js | 157 ------------------------------------ src/ol/source/VectorTile.js | 46 ++++++++++- 2 files changed, 45 insertions(+), 158 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 07f255d072..a0c9fa7dbb 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -98,163 +98,6 @@ olx.source.TileUTFGridOptions.prototype.tileJSON; olx.source.TileUTFGridOptions.prototype.url; -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * cacheSize: (number|undefined), - * format: (ol.format.Feature|undefined), - * overlaps: (boolean|undefined), - * projection: ol.ProjectionLike, - * state: (ol.source.State|undefined), - * tileClass: (function(new: ol.VectorTile, ol.TileCoord, - * ol.TileState, string, ol.format.Feature, - * ol.TileLoadFunctionType)|undefined), - * tileGrid: (ol.tilegrid.TileGrid|undefined), - * tileLoadFunction: (ol.TileLoadFunctionType|undefined), - * tileUrlFunction: (ol.TileUrlFunctionType|undefined), - * url: (string|undefined), - * urls: (Array.|undefined), - * wrapX: (boolean|undefined), - * transition: (number|undefined)}} - */ -olx.source.VectorTileOptions; - - -/** - * Attributions. - * @type {ol.AttributionLike|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.attributions; - - -/** - * Cache size. Default is `128`. - * @type {number|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.cacheSize; - - -/** - * Feature format for tiles. Used and required by the default - * `tileLoadFunction`. - * @type {ol.format.Feature|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.format; - - -/** - * This source may have overlapping geometries. Default is `true`. Setting this - * to `false` (e.g. for sources with polygons that represent administrative - * boundaries or TopoJSON sources) allows the renderer to optimise fill and - * stroke operations. - * @type {boolean|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.overlaps; - - -/** - * Projection. - * @type {ol.ProjectionLike} - * @api - */ -olx.source.VectorTileOptions.prototype.projection; - - -/** - * Source state. - * @type {ol.source.State|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.state; - - -/** - * Class used to instantiate vector tiles. Default is {@link ol.VectorTile}. - * @type {function(new: ol.VectorTile, ol.TileCoord, - * ol.TileState, string, ol.format.Feature, - * ol.TileLoadFunctionType)|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.tileClass; - - -/** - * Tile grid. - * @type {ol.tilegrid.TileGrid|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.tileGrid; - - -/** - * Optional function to load a tile given a URL. Could look like this: - * ```js - * function(tile, url) { - * tile.setLoader(function() { - * var data = // ... fetch data - * var format = tile.getFormat(); - * tile.setFeatures(format.readFeatures(data, { - * // uncomment the line below for ol.format.MVT only - * extent: tile.getExtent(), - * featureProjection: map.getView().getProjection() - * })); - * }; - * }); - * ``` - * @type {ol.TileLoadFunctionType|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.tileLoadFunction; - - -/** - * Optional function to get tile URL given a tile coordinate and the projection. - * @type {ol.TileUrlFunctionType|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.tileUrlFunction; - - -/** - * URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be - * used instead of defining each one separately in the `urls` option. - * @type {string|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.url; - - -/** - * An array of URL templates. - * @type {Array.|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.urls; - - -/** - * Whether to wrap the world horizontally. When set to `false`, only one world - * will be rendered. When set to `true`, tiles will be wrapped horizontally to - * render multiple worlds. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.wrapX; - - -/** - * Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - * @type {number|undefined} - * @api - */ -olx.source.VectorTileOptions.prototype.transition; - - /** * @typedef {{cacheSize: (number|undefined), * layer: string, diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index d62c8d3f09..1df6310cc9 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -10,6 +10,50 @@ import UrlTile from '../source/UrlTile.js'; import {getKeyZXY} from '../tilecoord.js'; import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid.js'; +/** + * @typedef {Object} Options + * @property {ol.AttributionLike} [attributions] Attributions. + * @property {number} [cacheSize=128] Cache size. + * @property {ol.format.Feature} [format] Feature format for tiles. Used and required by the default. + * @property {boolean} [overlaps=true] This source may have overlapping geometries. Setting this + * to `false` (e.g. for sources with polygons that represent administrative + * boundaries or TopoJSON sources) allows the renderer to optimise fill and + * stroke operations. + * @property {ol.ProjectionLike} projection Projection. + * @property {ol.source.State} [state] Source state. + * @property {function(new: ol.VectorTile, ol.TileCoord, + * ol.TileState, string, ?string, + * ol.TileLoadFunctionType)} [tileClass] Class used to instantiate image tiles. + * Default is {@link ol.VectorTile}. + * @property {ol.tilegrid.TileGrid} [tileGrid] Tile grid. + * @property {ol.TileLoadFunctionType} [tileLoadFunction] + * Optional function to load a tile given a URL. Could look like this: + * ```js + * function(tile, url) { + * tile.setLoader(function() { + * var data = // ... fetch data + * var format = tile.getFormat(); + * tile.setFeatures(format.readFeatures(data, { + * // uncomment the line below for ol.format.MVT only + * extent: tile.getExtent(), + * featureProjection: map.getView().getProjection() + * })); + * }; + * }); + * @property {ol.TileUrlFunctionType} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection. + * @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. + * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be + * used instead of defining each one separately in the `urls` option. + * @property {Array.} [urls] An array of URL templates. + * @property {boolean} [wrapX=true] Whether to wrap the world horizontally. + * When set to `false`, only one world + * will be rendered. When set to `true`, tiles will be wrapped horizontally to + * render multiple worlds. + * @property {number} [transition] Duration of the opacity transition for rendering. + * To disable the opacity transition, pass `transition: 0`. + */ + + /** * @classdesc * Class for layer sources providing vector data divided into a tile grid, to be @@ -23,7 +67,7 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid. * @constructor * @fires ol.source.Tile.Event * @extends {ol.source.UrlTile} - * @param {olx.source.VectorTileOptions} options Vector tile options. + * @param {module:ol/source/VectorTile~Options=} options Vector tile options. * @api */ const VectorTileSource = function(options) {