diff --git a/externs/olx.js b/externs/olx.js index 3ebe0f635f..b13b9c090e 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -4123,7 +4123,8 @@ olx.source.ClusterOptions.prototype.wrapX; /** * @typedef {{preemptive: (boolean|undefined), - * url: string}} + * tileJSON: (TileJSON|undefined), + * url: (string|undefined)}} * @api */ olx.source.TileUTFGridOptions; @@ -4143,7 +4144,18 @@ olx.source.TileUTFGridOptions.prototype.preemptive; /** - * @type {string} + * TileJSON configuration for this source. If not provided, `url` must be + * configured. + * @type {TileJSON|undefined} + * @api + */ +olx.source.TileUTFGridOptions.prototype.tileJSON; + + +/** + * TileJSON endpoint that provides the configuration for this source. Request + * will be made through JSONP. If not provided, `tileJSON` must be configured. + * @type {string|undefined} * @api */ olx.source.TileUTFGridOptions.prototype.url; diff --git a/src/ol/source/tileutfgridsource.js b/src/ol/source/tileutfgridsource.js index 22d7b2b9dd..a074e381e2 100644 --- a/src/ol/source/tileutfgridsource.js +++ b/src/ol/source/tileutfgridsource.js @@ -49,7 +49,13 @@ ol.source.TileUTFGrid = function(options) { */ this.template_ = undefined; - ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this)); + if (options.url) { + ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this)); + } else if (options.tileJSON) { + this.handleTileJSONResponse(options.tileJSON); + } else { + goog.asserts.fail('Either url or tileJSON options must be provided'); + } }; goog.inherits(ol.source.TileUTFGrid, ol.source.Tile);