Merge pull request #122 from CartoDB/cors-check

Checks for image-filters when preloading image-file
This commit is contained in:
Francisco Dans 2015-02-10 14:17:52 +01:00
commit d27f9b0919

View File

@ -323,7 +323,10 @@ var filters = require('./torque_filters');
if (typeof self._icons.itemsToLoad === 'undefined'){
this._icons.itemsToLoad = img_names.length;
}
new_img.crossOrigin = "Anonymous";
var filtered = self._shader.getLayers().some(function(layer){return typeof layer.shader["image-filters"] !== "undefined"});
if (filtered){
new_img.crossOrigin = 'Anonymous';
}
new_img.onload = function(e){
self._icons[this.src] = this;
if (Object.keys(self._icons).length === img_names.length + 1){
@ -335,8 +338,12 @@ var filters = require('./torque_filters');
}
};
new_img.onerror = function(){
console.log("wililo");
self._forcePoints = true;
self.clearSpriteCache();
if(filtered){
console.info("Only CORS-enabled, or same domain image-files can be used in combination with image-filters");
}
console.error("Couldn't get marker-file " + this.src);
};
this.itemsToLoad++;