Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = () => {
if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
if (xmlHttp.responseText) {
try {
resolve(JSON.parse(xmlHttp.responseText));
} catch (er) {
reject(er);
}
}
}
};
xmlHttp.open('GET', fixUrlStr(url), true); // true for asynchronous
xmlHttp.send();
});
}
private _updateItemsParams(item: TreeGroup | TreeLayer, webMap: WebMap, data: ResourceItem) {
if (item) {
if (item.item_type === 'group' || item.item_type === 'root') {
if (item.children) {
item.children = item.children.map(x => this._updateItemsParams(x, webMap, data));
}
if (item.item_type === 'root') {
item.display_name = data.resource.display_name;
}
} else if (item.item_type === 'layer') {
const url = fixUrlStr(this.options.baseUrl + '/api/component/render/image');
const resourceId = item.layer_style_id;
item.url = url;
item.resourceId = resourceId;
item.updateWmsParams = params => updateWmsParams(params, resourceId);
item = {
...item,
...getLayerAdapterOptions(
{
adapter: item.layer_adapter.toUpperCase() as NgwLayerAdapterType,
resourceId
},
webMap,
this.options.baseUrl
)
};
}