diff --git a/src/ol/source/formatvectorsource.js b/src/ol/source/formatvectorsource.js
index 1ceba4d297..7c94bf5fa2 100644
--- a/src/ol/source/formatvectorsource.js
+++ b/src/ol/source/formatvectorsource.js
@@ -48,12 +48,14 @@ goog.inherits(ol.source.FormatVector, ol.source.Vector);
/**
* @param {goog.Uri|string} url URL.
- * @param {function(this: T, Array.
)} callback Callback.
- * @param {T} thisArg Value to use as `this` when executing `callback`.
+ * @param {function(this: T, Array.)} success Success Callback.
+ * @param {function(this: T)} error Error callback.
+ * @param {T} thisArg Value to use as `this` when executing `success` or
+ * `error`.
* @template T
*/
ol.source.FormatVector.prototype.loadFeaturesFromURL =
- function(url, callback, thisArg) {
+ function(url, success, error, thisArg) {
var xhrIo = new goog.net.XhrIo();
var type = this.format.getType();
var responseType;
@@ -97,13 +99,13 @@ ol.source.FormatVector.prototype.loadFeaturesFromURL =
goog.asserts.fail();
}
if (goog.isDefAndNotNull(source)) {
- callback.call(thisArg, this.readFeatures(source));
+ success.call(thisArg, this.readFeatures(source));
} else {
this.setState(ol.source.State.ERROR);
goog.asserts.fail();
}
} else {
- this.setState(ol.source.State.ERROR);
+ error.call(thisArg);
}
goog.dispose(xhrIo);
}, false, this);
diff --git a/src/ol/source/staticvectorsource.js b/src/ol/source/staticvectorsource.js
index ca5c5362c6..30b5e330e7 100644
--- a/src/ol/source/staticvectorsource.js
+++ b/src/ol/source/staticvectorsource.js
@@ -48,13 +48,15 @@ ol.source.StaticVector = function(options) {
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
this.setState(ol.source.State.LOADING);
if (goog.isDef(options.url)) {
- this.loadFeaturesFromURL(options.url, this.onFeaturesLoaded_, this);
+ this.loadFeaturesFromURL(options.url,
+ this.onFeaturesLoadedSuccess_, this.onFeaturesLoadedError_, this);
}
if (goog.isDef(options.urls)) {
var urls = options.urls;
var i, ii;
for (i = 0, ii = urls.length; i < ii; ++i) {
- this.loadFeaturesFromURL(urls[i], this.onFeaturesLoaded_, this);
+ this.loadFeaturesFromURL(urls[i],
+ this.onFeaturesLoadedSuccess_, this.onFeaturesLoadedError_, this);
}
}
}
@@ -63,11 +65,19 @@ ol.source.StaticVector = function(options) {
goog.inherits(ol.source.StaticVector, ol.source.FormatVector);
+/**
+ * @private
+ */
+ol.source.StaticVector.prototype.onFeaturesLoadedError_ = function() {
+ this.setState(ol.source.State.ERROR);
+};
+
+
/**
* @param {Array.} features Features.
* @private
*/
-ol.source.StaticVector.prototype.onFeaturesLoaded_ = function(features) {
+ol.source.StaticVector.prototype.onFeaturesLoadedSuccess_ = function(features) {
this.addFeaturesInternal(features);
this.setState(ol.source.State.READY);
};
diff --git a/src/ol/source/tilevectorsource.js b/src/ol/source/tilevectorsource.js
index 17ec6a86b6..307c9717e8 100644
--- a/src/ol/source/tilevectorsource.js
+++ b/src/ol/source/tilevectorsource.js
@@ -185,6 +185,15 @@ ol.source.TileVector.prototype.loadFeatures =
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
var tileCoord = [z, 0, 0];
var x, y;
+ /**
+ * @param {string} tileKey Tile key.
+ * @param {Array.} features Features.
+ * @this {ol.source.TileVector}
+ */
+ function success(tileKey, features) {
+ tiles[tileKey] = features;
+ this.setState(ol.source.State.READY);
+ }
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
var tileKey = this.getTileKeyZXY_(z, x, y);
@@ -196,16 +205,8 @@ ol.source.TileVector.prototype.loadFeatures =
var url = tileUrlFunction(tileCoord, 1, projection);
if (goog.isDef(url)) {
tiles[tileKey] = [];
- this.loadFeaturesFromURL(url, goog.partial(
- /**
- * @param {string} tileKey Tile key.
- * @param {Array.} features Features.
- * @this {ol.source.TileVector}
- */
- function(tileKey, features) {
- tiles[tileKey] = features;
- this.setState(ol.source.State.READY);
- }, tileKey), this);
+ this.loadFeaturesFromURL(url, goog.partial(success, tileKey),
+ goog.nullFunction, this);
}
}
}
diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js
index d0b63a6975..a91a78fc02 100644
--- a/src/ol/tilegrid/tilegrid.js
+++ b/src/ol/tilegrid/tilegrid.js
@@ -2,6 +2,7 @@ goog.provide('ol.tilegrid.TileGrid');
goog.require('goog.array');
goog.require('goog.asserts');
+goog.require('goog.functions');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.TileCoord');
@@ -101,12 +102,16 @@ ol.tilegrid.TileGrid.tmpTileCoord_ = [0, 0, 0];
/**
+ * Returns the identity function. May be overridden in subclasses.
* @param {{extent: (ol.Extent|undefined),
* wrapX: (boolean|undefined)}=} opt_options Options.
* @return {function(ol.TileCoord, ol.proj.Projection, ol.TileCoord=):
* ol.TileCoord} Tile coordinate transform.
*/
-ol.tilegrid.TileGrid.prototype.createTileCoordTransform = goog.abstractMethod;
+ol.tilegrid.TileGrid.prototype.createTileCoordTransform =
+ function(opt_options) {
+ return goog.functions.identity;
+};
/**