diff --git a/examples/tile-vector.js b/examples/tile-vector.js index 6822562e53..84e1b9e17b 100644 --- a/examples/tile-vector.js +++ b/examples/tile-vector.js @@ -18,8 +18,7 @@ var vectorSource = new ol.source.TileVector({ tileGrid: new ol.tilegrid.XYZ({ maxZoom: 19 }), - url: 'http://www.somebits.com:8001/rivers/{z}/{x}/{y}.json', - z: 11 + url: 'http://www.somebits.com:8001/rivers/{z}/{x}/{y}.json' }); var styleCache = {}; diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 422a3ded51..f3b1a22684 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -724,7 +724,6 @@ * @property {string|undefined} url URL template. Must include `{x}`, `{y}`, * and `{z}` placeholders. * @property {Array.|undefined} urls An array of URL templates. - * @property {number} z Z value of tiles to request. FIXME remove! */ /** diff --git a/src/ol/source/tilevectorsource.js b/src/ol/source/tilevectorsource.js index f79b7686e1..cf64f35430 100644 --- a/src/ol/source/tilevectorsource.js +++ b/src/ol/source/tilevectorsource.js @@ -1,7 +1,3 @@ -// FIXME implement getClosestFeatureToCoordinate -// FIXME implement getExtent -// FIXME handle different Zs - goog.provide('ol.source.TileVector'); goog.require('goog.array'); @@ -30,13 +26,6 @@ ol.source.TileVector = function(options) { }); var tileGrid = options.tileGrid; - var z = options.z; - - /** - * @private - * @type {number} - */ - this.resolution_ = tileGrid.getResolution(z); /** * @private @@ -64,12 +53,6 @@ ol.source.TileVector = function(options) { */ this.tiles_ = {}; - /** - * @private - * @type {number} - */ - this.z_ = z; - if (goog.isDef(options.tileUrlFunction)) { this.setTileUrlFunction(options.tileUrlFunction); } else if (goog.isDef(options.urls)) { @@ -105,34 +88,24 @@ ol.source.TileVector.prototype.clear = function() { /** * @inheritDoc */ -ol.source.TileVector.prototype.forEachFeature = function(f, opt_this) { - var tiles = this.tiles_; - var tileKey; - for (tileKey in tiles) { - var features = tiles[tileKey]; - var i, ii; - for (i = 0, ii = features.length; i < ii; ++i) { - var result = f.call(opt_this, features[i]); - if (result) { - return result; - } - } - } - return undefined; -}; +ol.source.TileVector.prototype.forEachFeature = goog.abstractMethod; /** * @inheritDoc */ -ol.source.TileVector.prototype.forEachFeatureInExtent = - function(extent, f, opt_this) { - var resolution = this.resolution_; +ol.source.TileVector.prototype.forEachFeatureInExtent = goog.abstractMethod; + + +/** + * @inheritDoc + */ +ol.source.TileVector.prototype.forEachFeatureInExtentAtResolution = + function(extent, resolution, f, opt_this) { var tileGrid = this.tileGrid_; var tiles = this.tiles_; - var z = this.z_; - var tileRange = - tileGrid.getTileRangeForExtentAndResolution(extent, resolution); + var z = tileGrid.getZForResolution(resolution); + var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z); var x, y; for (x = tileRange.minX; x <= tileRange.maxX; ++x) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) { @@ -183,17 +156,7 @@ ol.source.TileVector.prototype.getFeatures = function() { /** * @inheritDoc */ -ol.source.TileVector.prototype.getFeaturesInExtent = function(extent) { - var features = []; - this.forEachFeatureInExtent(extent, - /** - * @param {ol.Feature} feature Feature. - */ - function(feature) { - features.push(feature); - }); - return features; -}; +ol.source.TileVector.prototype.getFeaturesInExtent = goog.abstractMethod; /** @@ -213,14 +176,12 @@ ol.source.TileVector.prototype.getTileKeyZXY_ = function(z, x, y) { */ ol.source.TileVector.prototype.loadFeatures = function(extent, resolution, projection) { - // FIXME should use resolution argument rather than this.resolution_ var tileCoordTransform = this.tileCoordTransform_; var tileGrid = this.tileGrid_; var tileUrlFunction = this.tileUrlFunction_; var tiles = this.tiles_; - var z = this.z_; - var tileRange = - tileGrid.getTileRangeForExtentAndResolution(extent, this.resolution_); + var z = tileGrid.getZForResolution(resolution); + var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z); var tileCoord = new ol.TileCoord(z, 0, 0); var x, y; for (x = tileRange.minX; x <= tileRange.maxX; ++x) {