openlayers/ol3 — pull request #2497 by ahocevar (2014-08-07 08:52:11+00:00)
Title: TileUrlFunction only replaces first instance of placeholder variables

I'm using a local copy of OSM data which is stored on my site in a /{z}/{z}_{x}_{y}.png fashion.
The TileUrlFunction to do the replacement of the placeholder vars is only doing a simple replace, which gets the first search only. Please change to regex /g option to replace all instances, thanks!
I would offer patch, but I'm on Windows and have not been able to get dev env setup yet. This should be an easy fix:
```js
ol.TileUrlFunction.createFromTemplate = function(template) {
return (
/**
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {number} pixelRatio Pixel ratio.
* @param {ol.proj.Projection} projection Projection.
* @return {string|undefined} Tile URL.
*/
function(tileCoord, pixelRatio, projection) {
if (goog.isNull(tileCoord)) {
return undefined;
} else {
return template.replace(/\{z\}/g, tileCoord.z.toString())
.replace(/\{x\}/g, tileCoord.x.toString())
.replace(/\{y\}/g, tileCoord.y.toString())
.replace(/\{-y\}/g, function() {
var y = (1 << tileCoord.z) - tileCoord.y - 1;
return y.toString();
});
}
});
};
```