Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getOptionsFromMap = () => {
const {
map,
resolutionsFilter
} = this.props;
if (!_isEmpty(this.state.scales)) {
Logger.debug('Array with scales found. Returning');
return [];
}
if (!map) {
Logger.warn('Map component not found. Could not initialize options array.');
return [];
}
let scales = [];
let view = map.getView();
// use existing resolutions array if exists
let resolutions = view.getResolutions();
if (_isEmpty(resolutions)) {
for (let currentZoomLevel = view.getMaxZoom(); currentZoomLevel >= view.getMinZoom(); currentZoomLevel--) {
let resolution = view.getResolutionForZoom(currentZoomLevel);
if (resolutionsFilter(resolution)) {
this.pushScale(scales, resolution, view);
}
}
} else {
let reversedResolutions = _reverse(_clone(resolutions));
onLayerAddToMap,
wmsLayers,
map
} = this.props;
if (onLayerAddToMap) {
onLayerAddToMap(wmsLayers);
} else if (map) {
wmsLayers.forEach(layer => {
// Add layer to map if it is not added yet
if (!map.getLayers().getArray().includes(layer) ) {
map.addLayer(layer);
}
});
} else {
Logger.warn('Neither map nor onLayerAddToMap given in props. Will do nothing.');
}
}
source.getUrls() ? source.getUrls()[0] : ''
: source.getUrl();
const params = {
LAYER: source.getParams().LAYERS,
VERSION: '1.3.0',
SERVICE: 'WMS',
REQUEST: 'getLegendGraphic',
FORMAT: 'image/png'
};
const queryString = UrlUtil.objectToRequestString(
Object.assign(params, extraParams));
return /\?/.test(url) ? `${url}&${queryString}` : `${url}?${queryString}`;
} else {
Logger.warn(`Source of "${layer.get('name')}" is currently not supported `
+ `by MapUtil.getLegendGraphicUrl.`);
return;
}
}
setMapLayers = () => {
const {
layers
} = this.props;
if (layers.length < 2) {
Logger.warn(`LayerSwitcher requires two or more layers.`);
}
this._map.getLayers().clear();
this._layerClones = layers.map((layer, index) => {
const layerClone = this.cloneLayer(layer);
if (layerClone.getVisible()) {
this._visibleLayerIndex = index;
}
this._map.addLayer(layerClone);
return layerClone;
});
}
treeNodeFromLayer(layer: OlLayerBase) {
let childNodes;
let treeNode;
if (layer instanceof OlLayerGroup) {
if (!layer.getVisible()) {
Logger.warn('Your map configuration contains layerGroups that are' +
'invisible. This might lead to buggy behaviour.');
}
let childLayers = layer.getLayers().getArray()
.filter(this.props.filterFunction);
childNodes = childLayers.map((childLayer) => {
return this.treeNodeFromLayer(childLayer);
});
childNodes.reverse();
} else {
if (!this.hasListener(layer, 'change:visible', this.onLayerChangeVisible)) {
const eventKey = layer.on('change:visible', this.onLayerChangeVisible);
this.olListenerKeys.push(eventKey);
}
}
treeNode =
constructor(props: DigitizeButtonProps) {
super(props);
if (!props.drawType && !props.editType) {
Logger.warn('Neither "drawType" nor "editType" was provided. Digitize ' +
'button won\'t work properly!');
}
this.state = {
digitizeLayer: null,
interactions: [],
showLabelPrompt: false,
textLabel: ''
};
}
onError() {
Logger.warn(`Image error for legend of "${this.props.layer.get('name')}".`);
}
constructor(props: WindowProps) {
super(props);
const id = props.id || _uniqueId('window-');
const { parentId } = this.props;
this._parent = document.getElementById(parentId);
if (!this._parent) {
Logger.warn('No parent element was found! Please ensure that parentId ' +
'parameter was set correctly (default value is `app`)');
}
const div = document.createElement('div');
div.id = id;
this._elementDiv = div;
this.state = {
id: id,
resizing: false
};
}
render() {
const {
map
} = this.context;
if (!map) {
Logger.warn('You\'re trying to mappify a component without any map ' +
'in the context. Did you implement the MapProvider?');
}
return (
);
}
};