Make ol.source.TileVector inherit from ol.source.Vector

This commit is contained in:
Éric Lemoine
2015-04-04 15:15:41 +02:00
parent bdb326c310
commit bb0ee1e6e9
2 changed files with 19 additions and 18 deletions

View File

@@ -5,8 +5,9 @@ goog.require('goog.asserts');
goog.require('goog.object');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.source.FormatVector');
goog.require('ol.featureloader');
goog.require('ol.source.State');
goog.require('ol.source.Vector');
goog.require('ol.tilegrid.TileGrid');
@@ -17,7 +18,7 @@ goog.require('ol.tilegrid.TileGrid');
* into tiles in a fixed grid pattern.
*
* @constructor
* @extends {ol.source.FormatVector}
* @extends {ol.source.Vector}
* @param {olx.source.TileVectorOptions} options Options.
* @api
*/
@@ -25,11 +26,20 @@ ol.source.TileVector = function(options) {
goog.base(this, {
attributions: options.attributions,
format: options.format,
logo: options.logo,
projection: options.projection
projection: undefined,
state: ol.source.State.READY
});
/**
* @private
* @type {ol.format.Feature}
*/
this.format_ = options.format;
goog.asserts.assert(goog.isDefAndNotNull(this.format_),
'ol.source.TileVector requires a format');
/**
* @private
* @type {ol.tilegrid.TileGrid}
@@ -63,7 +73,7 @@ ol.source.TileVector = function(options) {
}
};
goog.inherits(ol.source.TileVector, ol.source.FormatVector);
goog.inherits(ol.source.TileVector, ol.source.Vector);
/**
@@ -258,7 +268,7 @@ ol.source.TileVector.prototype.loadFeatures =
*/
function success(tileKey, features) {
tiles[tileKey] = features;
this.setState(ol.source.State.READY);
this.changed();
}
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
@@ -271,8 +281,9 @@ ol.source.TileVector.prototype.loadFeatures =
var url = tileUrlFunction(tileCoord, 1, projection);
if (goog.isDef(url)) {
tiles[tileKey] = [];
this.loadFeaturesFromURL(url, goog.partial(success, tileKey),
goog.nullFunction, this);
var loader = ol.featureloader.loadFeaturesXhr(url, this.format_,
goog.partial(success, tileKey));
loader.call(this, extent, resolution, projection);
}
}
}