26 lines
1023 B
JavaScript
26 lines
1023 B
JavaScript
let list = ['icon-py', 'icon-edit', 'icon-add', 'icon-add2', 'icon-minus', 'icon-play', 'icon-pause', 'icon-updateheight', 'icon-draw', 'icon-positions', 'icon-reset', 'icon-xj', 'icon-yj', 'icon-zj', 'icon-close', 'icon-query', 'icon-route', 'icon-copy', 'icon-load', 'icon-rubric', 'icon-pen', 'icon-cross']
|
|
function setSvg() {
|
|
let svgElm = document.createElement('svg');
|
|
svgElm.xmlns = 'http://www.w3.org/2000/svg'
|
|
svgElm.style.width = 0
|
|
svgElm.style.height = 0
|
|
svgElm.style.position = 'absolute'
|
|
svgElm.style.overflow = 'hidden'
|
|
document.body.appendChild(svgElm)
|
|
const parser = new DOMParser()
|
|
for (let i = 0; i < list.length; i++) {
|
|
let name = list[i]
|
|
fetch(Cesium.buildModuleUrl(`../custom/img/${name}.svg`))
|
|
.then(r => r.text())
|
|
.then(b => {
|
|
const xmlDoc = parser.parseFromString(b, 'text/xml').getElementsByTagName('svg')[0]
|
|
if(xmlDoc) {
|
|
xmlDoc.id = 'yj-' + name
|
|
svgElm.appendChild(xmlDoc)
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
export { setSvg } |