Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function clearStyleFunction(def, vectorStyleId, vectorStyles, layer, state) {
var styleFunction;
var layerId = def.id;
var glStyle = vectorStyles[layerId];
var olMap = lodashGet(state, 'legacy.map.ui.selected');
if (olMap) {
lodashEach(olMap.getLayers().getArray(), subLayer => {
if (subLayer.wv.id === layerId) {
layer = subLayer;
}
});
}
styleFunction = stylefunction(layer, glStyle, vectorStyleId);
if (glStyle.name === 'Orbit Tracks') {
// Filter time by 5 mins
layer.setStyle(function(feature, resolution) {
var minute;
var minutes = feature.get('label');
if (minutes) {
minute = minutes.split(':');
}
if ((minute && minute[1] % 5 === 0) || feature.getType() === 'LineString') {
return styleFunction(feature, resolution);
}
});
}
return update(vectorStyles, { layerId: { maps: { $unset: ['custom'] } } });
}
layer = subLayer;
}
});
}
} else {
lodashEach(layerGroups, subLayer => {
if (subLayer.wv && (subLayer.wv.id === layerId)) {
layer = subLayer;
}
});
}
});
}
// Apply mapbox-gl styles
styleFunction = stylefunction(layer, glStyle, vectorStyleId);
// Filter Orbit Tracks
if (glStyle.name === 'Orbit Tracks') {
// Filter time by 5 mins
layer.setStyle(function(feature, resolution) {
var minute;
var minutes = feature.get('label');
if (minutes) {
minute = minutes.split(':');
}
if ((minute && minute[1] % 5 === 0) || feature.getType() === 'LineString') {
return styleFunction(feature, resolution);
}
});
} else if (glStyle.name === 'SEDAC' &&
((selected[layerId] && selected[layerId].length))) {
const selectedFeatures = selected[layerId];
.then((glStyle) => {
stylefunction(layer, glStyle, 'states');
if (map.getLayers().getArray().indexOf(layer) === -1) {
map.addLayer(layer);
}
});
this.getMapboxGlStyle(layerOptions.mapboxStyle.url).subscribe(res => {
stylefunction(layer.ol, res, layerOptions.mapboxStyle.source);
});
}