gets icon filenames via regex

This commit is contained in:
Francisco Dans 2015-01-07 17:42:19 +01:00
parent 06ed46f6b8
commit 1113a100d1

View File

@ -83,6 +83,8 @@ var carto = global.carto || require('carto');
//
setCartoCSS: function(cartocss) {
// clean sprites
this._getIcons(cartocss);
console.log(this._iconNames);
this.setShader(new carto.RendererJS().render(cartocss));
},
@ -256,6 +258,17 @@ var carto = global.carto || require('carto');
}
return positions;
},
_getIcons: function(cartocss){
var re = /marker-file.*\)/g;
this._iconNames = cartocss.match(re).map(function(element){
element = element.replace("url(", "")
.replace(")", "")
.replace(";", "")
.replace("marker-file:", "")
.trim();
return element;
});
},
// return the value for x, y (tile coordinates)
// null for no value
@ -292,7 +305,7 @@ var carto = global.carto || require('carto');
return null;
}
};
});
// exports public api