Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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',
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;
}
}
doSearch() {
const baseParams = {
format: this.props.format,
viewbox: this.props.viewbox,
bounded: this.props.bounded,
polygon_geojson: this.props.polygon_geojson,
addressdetails: this.props.addressdetails,
limit: this.props.limit,
countrycodes: this.props.countrycodes,
q: this.state.searchTerm
};
const getRequestParams = UrlUtil.objectToRequestString(baseParams);
fetch(`${this.props.nominatimBaseUrl}${getRequestParams}`)
.then(response => response.json())
.then(this.onFetchSuccess.bind(this))
.catch(this.onFetchError.bind(this));
}
fetchCrs = (searchVal) => {
const { crsApiUrl } = this.props;
const queryParameters = {
format: 'json',
q: searchVal
};
return fetch(`${crsApiUrl}?${UrlUtil.objectToRequestString(queryParameters)}`)
.then(response => response.json());
}