Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setLayerVisibility(layer: OlLayerBase, visibility: boolean) {
if (!(layer instanceof OlLayerBase) || !_isBoolean(visibility)) {
Logger.error('setLayerVisibility called without layer or visiblity.');
return;
}
if (layer instanceof OlLayerGroup) {
layer.getLayers().forEach((subLayer) => {
this.setLayerVisibility(subLayer, visibility);
});
} else {
layer.setVisible(visibility);
}
}
onFetchError(error: string) {
Logger.error(`Error while requesting Nominatim: ${error}`);
}
onFetchError(error: string) {
const {
onFetchError
} = this.props;
Logger.error(`Error while requesting WFS GetFeature: ${error}`);
this.setState({
fetching: false
}, () => {
if (isFunction(onFetchError)) {
onFetchError(error);
}
});
}
static getLegendGraphicUrl(layer, extraParams) {
if (!layer) {
Logger.error('No layer passed to MapUtil.getLegendGraphicUrl.');
return;
}
const source = layer.getSource();
if (!(layer instanceof OlLayerBase) || !source) {
Logger.error('Invalid layer passed to MapUtil.getLegendGraphicUrl.');
return;
}
const isTiledWMS = source instanceof OlSourceTileWMS;
const isImageWMS = source instanceof OlSourceImageWMS;
if (isTiledWMS || isImageWMS) {
const source = layer.getSource();
const url = isTiledWMS ?
source.getUrls() ? source.getUrls()[0] : ''
: source.getUrl();
const params = {
LAYER: source.getParams().LAYERS,
VERSION: '1.3.0',
SERVICE: 'WMS',
REQUEST: 'getLegendGraphic',
static getAllLayers(collection, filter = (() => true)) {
if (!(collection instanceof OlMap) && !(collection instanceof OlLayerGroup)) {
Logger.error('Input parameter collection must be from type `ol.Map`' +
'or `ol.layer.Group`.');
return [];
}
var layers = collection.getLayers().getArray();
var allLayers = [];
layers.forEach(function(layer) {
if (layer instanceof OlLayerGroup) {
MapUtil.getAllLayers(layer).forEach((layeri) => {
if (filter(layeri)) {
allLayers.push(layeri);
}
});
}
if (filter(layer)) {
onFetchError(error: string) {
Logger.error(`Error while requesting WFS GetFeature: ${error}`);
this.setState({
fetching: false
});
}
onFetchError(error: string) {
Logger.error(`Error while requesting in CoordinateReferenceSystemCombo: ${error}`);
}