New crossOriginKeyword property.
Set to 'anonymous' for Layer.OSM and Layer.Bing, and not used by default for other layers.
This commit is contained in:
@@ -107,6 +107,9 @@ OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
|
|
||||||
var newArgs = [name, null, options];
|
var newArgs = [name, null, options];
|
||||||
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs);
|
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs);
|
||||||
|
this.tileOptions = OpenLayers.Util.extend({
|
||||||
|
crossOriginKeyword: 'anonymous'
|
||||||
|
}, this.options.tileOptions);
|
||||||
this.loadMetadata();
|
this.loadMetadata();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
|
|||||||
* layer option can be set in this object (e.g.
|
* layer option can be set in this object (e.g.
|
||||||
* <OpenLayers.Layer.Grid.buffer>).
|
* <OpenLayers.Layer.Grid.buffer>).
|
||||||
*/
|
*/
|
||||||
|
initialize: function(name, url, options) {
|
||||||
|
OpenLayers.Layer.XYZ.prototype.initialize.apply(this, arguments);
|
||||||
|
this.tileOptions = OpenLayers.Util.extend({
|
||||||
|
crossOriginKeyword: 'anonymous'
|
||||||
|
}, this.options && this.options.tileOptions);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: clone
|
* Method: clone
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
* the tile image.
|
* the tile image.
|
||||||
*/
|
*/
|
||||||
canvasContext: null,
|
canvasContext: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: crossOriginKeyword
|
||||||
|
* The value of the crossorigin keyword to use when loading images. This is
|
||||||
|
* only relevant when using <getCanvasContext> for tiles from remote
|
||||||
|
* origins and should be set to either 'anonymous' or 'use-credentials'
|
||||||
|
* for servers that send Access-Control-Allow-Origin headers with their
|
||||||
|
* tiles.
|
||||||
|
*/
|
||||||
|
crossOriginKeyword: null,
|
||||||
|
|
||||||
/** TBD 3.0 - reorder the parameters to the init function to remove
|
/** TBD 3.0 - reorder the parameters to the init function to remove
|
||||||
* URL. the getUrl() function on the layer gets called on
|
* URL. the getUrl() function on the layer gets called on
|
||||||
@@ -305,7 +315,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
} else {
|
} else {
|
||||||
OpenLayers.Event.observe(img, "load", load);
|
OpenLayers.Event.observe(img, "load", load);
|
||||||
OpenLayers.Event.observe(img, "error", load);
|
OpenLayers.Event.observe(img, "error", load);
|
||||||
img.crossOrigin = null;
|
delete img.crossOrigin;
|
||||||
img.src = this.blankImageUrl;
|
img.src = this.blankImageUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,7 +334,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
img.style.opacity = 0;
|
img.style.opacity = 0;
|
||||||
if (url) {
|
if (url) {
|
||||||
// don't set crossOrigin if the url is a data URL
|
// don't set crossOrigin if the url is a data URL
|
||||||
img.crossOrigin = url.substr(0, 5) === 'data:' ? null : '';
|
if (this.crossOriginKeyword && url.substr(0, 5 !== 'data:')) {
|
||||||
|
img.crossOrigin = this.crossOriginKeyword;
|
||||||
|
}
|
||||||
img.src = url;
|
img.src = url;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user