Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ensureHasNoRefs(style) {
const derefedStyle = {
...style,
layers: deref(style.layers)
}
return derefedStyle
}
let spriteImage, spriteImgSize;
if (spriteImageUrl) {
const img = new Image();
img.crossOrigin = 'anonymous';
img.onload = function() {
spriteImage = img;
spriteImgSize = [img.width, img.height];
olLayer.changed();
img.onload = null;
};
img.src = spriteImageUrl;
}
const allLayers = derefLayers(glStyle.layers);
const layersBySourceLayer = {};
const mapboxLayers = [];
let mapboxSource;
for (let i = 0, ii = allLayers.length; i < ii; ++i) {
const layer = allLayers[i];
const layerId = layer.id;
if (typeof source == 'string' && layer.source == source ||
source.indexOf(layerId) !== -1) {
const sourceLayer = layer['source-layer'];
if (!mapboxSource) {
mapboxSource = layer.source;
const source = glStyle.sources[mapboxSource];
if (!source) {
throw new Error(`Source "${mapboxSource}" is not defined`);
}