Add crossOrigin option

Co-Authored-By: Andreas Hocevar <andreas.hocevar@gmail.com>
This commit is contained in:
mike-000
2022-01-18 20:54:11 +00:00
parent 3e216edbe8
commit 70ee68c649
2 changed files with 3 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ export const SymbolType = {
* @property {ExpressionValue|Array<ExpressionValue, ExpressionValue>} size Size, mandatory. * @property {ExpressionValue|Array<ExpressionValue, ExpressionValue>} size Size, mandatory.
* @property {SymbolType} symbolType Symbol type to use, either a regular shape or an image. * @property {SymbolType} symbolType Symbol type to use, either a regular shape or an image.
* @property {string} [src] Path to the image to be used for the symbol. Only required with `symbolType: 'image'`. * @property {string} [src] Path to the image to be used for the symbol. Only required with `symbolType: 'image'`.
* @property {string} [crossOrigin='anonymous'] The `crossOrigin` attribute for loading `src`.
* @property {import("../color.js").Color|Array<ExpressionValue>|string} [color='#FFFFFF'] Color used for the representation (either fill, line or symbol). * @property {import("../color.js").Color|Array<ExpressionValue>|string} [color='#FFFFFF'] Color used for the representation (either fill, line or symbol).
* @property {ExpressionValue} [opacity=1] Opacity. * @property {ExpressionValue} [opacity=1] Opacity.
* @property {ExpressionValue} [rotation=0] Symbol rotation in radians. * @property {ExpressionValue} [rotation=0] Symbol rotation in radians.

View File

@@ -548,6 +548,8 @@ export function parseLiteralStyle(style) {
if (symbStyle.symbolType === 'image' && symbStyle.src) { if (symbStyle.symbolType === 'image' && symbStyle.src) {
const texture = new Image(); const texture = new Image();
texture.crossOrigin =
symbStyle.crossOrigin === undefined ? 'anonymous' : symbStyle.crossOrigin;
texture.src = symbStyle.src; texture.src = symbStyle.src;
builder builder
.addUniform('sampler2D u_texture') .addUniform('sampler2D u_texture')