diff --git a/src/ol/source/source.js b/src/ol/source/source.js
index a9650e8247..ed9e8a3d6a 100644
--- a/src/ol/source/source.js
+++ b/src/ol/source/source.js
@@ -150,6 +150,15 @@ ol.source.Source.prototype.getWrapX = function() {
};
+/**
+ * Refreshes the source and finally dispatches a 'change' event.
+ * @api
+ */
+ol.source.Source.prototype.refresh = function() {
+ this.changed();
+};
+
+
/**
* Set the attributions of the source.
* @param {Array.
} attributions Attributions.
diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js
index 88e793352e..57d7f5099e 100644
--- a/src/ol/source/tilesource.js
+++ b/src/ol/source/tilesource.js
@@ -290,6 +290,15 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction = function(tileCoord, op
};
+/**
+ * @inheritDoc
+ */
+ol.source.Tile.prototype.refresh = function() {
+ this.tileCache.clear();
+ this.changed();
+};
+
+
/**
* Marks a tile coord as being used, without triggering a load.
* @param {number} z Tile coordinate z.
diff --git a/test/spec/ol/source/source.test.js b/test/spec/ol/source/source.test.js
new file mode 100644
index 0000000000..49b5e523ed
--- /dev/null
+++ b/test/spec/ol/source/source.test.js
@@ -0,0 +1,29 @@
+goog.provide('ol.test.source.Source');
+
+describe('ol.source.Source', function() {
+
+ describe('constructor', function() {
+ it('returns a source', function() {
+ var source = new ol.source.Source({
+ projection: ol.proj.get('EPSG:4326')
+ });
+ expect(source).to.be.a(ol.source.Source);
+ });
+ });
+
+ describe('#refresh()', function() {
+ it('dispatches the change event', function() {
+ var source = new ol.source.Source({
+ projection: ol.proj.get('EPSG:4326')
+ });
+ var changedSpy = sinon.spy();
+ source.on('change', changedSpy);
+ source.refresh();
+ expect(changedSpy.called).to.be.ok();
+ });
+ });
+
+});
+
+goog.require('ol.proj');
+goog.require('ol.source.Source');
diff --git a/test/spec/ol/source/tilesource.test.js b/test/spec/ol/source/tilesource.test.js
index 2ec75b645c..779b829dee 100644
--- a/test/spec/ol/source/tilesource.test.js
+++ b/test/spec/ol/source/tilesource.test.js
@@ -170,6 +170,24 @@ describe('ol.source.Tile', function() {
});
});
+ describe('#refresh()', function() {
+ it('checks clearing of internal state', function() {
+ // create a source with one loaded tile
+ var source = new ol.test.source.TileMock({
+ '1/0/0': ol.TileState.LOADED
+ });
+ // check the loaded tile is there
+ var tile = source.getTile(1, 0, 0);
+ expect(tile).to.be.a(ol.Tile);
+ // check tile cache is filled
+ expect(source.tileCache.getCount()).to.eql(1);
+ // refresh the source
+ source.refresh();
+ // check tile cache after refresh (should be empty)
+ expect(source.tileCache.getCount()).to.eql(0);
+ });
+ });
+
});