defaults to point rendering in case marker-file errors, shows error in console

This commit is contained in:
Francisco Dans 2015-01-08 18:09:55 +01:00
parent 434684df09
commit 45e577c872

View File

@ -52,6 +52,7 @@ var carto = global.carto || require('carto');
this.setCartoCSS(this.options.cartocss || DEFAULT_CARTOCSS);
this.TILE_SIZE = 256;
this._icons = {};
this._forcePoints = false;
}
torque.extend(PointRenderer.prototype, torque.Event, {
@ -124,7 +125,7 @@ var carto = global.carto || require('carto');
ctx.translate(w/2, w/2);
var img_names = this._shader.getImageURLs();
if(img_names.length > 0){
if(img_names.length > 0 && !this._forcePoints){
if(Object.keys(this._icons).length === 0){
for (var i = 0; i<img_names.length; i++){
var new_img = this._createImage();
@ -143,7 +144,9 @@ var carto = global.carto || require('carto');
}
};
new_img.onerror = function(){
self._forcePoints = true;
self.clearSpriteCache();
console.error("Couldn't get marker-file " + this.src);
};
new_img.src = img_names[i];
}