Optimization: Re-use tile URL regex in BlueprintInputMapTiles

0.2
Brian Chirls 2014-12-09 11:50:09 -05:00
rodzic b5c3e0379f
commit 67f55b1eb4
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -13,6 +13,9 @@
// tilePath: "https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"
// }
// }
var tileURLRegex = /\{([zxy])\}/g;
VIZI.BlueprintInputMapTiles = function(options) {
var self = this;
@ -53,7 +56,8 @@
if (VIZI.DEBUG) console.log("Requesting tiles", tiles);
_.each(tiles, function(tile, key) {
var url = self.options.tilePath.replace(/\{([zxy])\}/g, function(value, key) {
tileURLRegex.lastIndex = 0;
var url = self.options.tilePath.replace(tileURLRegex, function(value, key) {
// Replace with paramter, otherwise keep existing value
return tile[key];
});