Skip to content

How to use olcs_tileLoadFunction #1293

@mvoermans

Description

@mvoermans

Hello, I'm trying to use the olcs_tileLoadFunction function but I cant find an example and I can't get it working. This is what I do:

source.set('olcs_tileLoadFunction', (tile, src) => { loadFunction(tile, src) })

export function loadFunction(tile, src) { const xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; xhr.addEventListener('loadend', function () { const data = this.response; if (data !== undefined) { tile.getImage().src = URL.createObjectURL(data); } else { tile.setState(TileState.ERROR); } }); xhr.addEventListener('error', function () { tile.setState(TileState.ERROR); }); xhr.open('GET', src); if(getToken() !== undefined) { xhr.setRequestHeader("Authorization", getToken()); } xhr.send(); }

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions