window.projectName = '/frontweb' window.mapBaseUrl = window.location.origin + window.projectName var src = [ { url: '/frontweb/js/arcgis_js_api/init.js', type: 'script' }, { url: '/frontweb/js/arcgis_js_api/esri/css/main.css', type: 'style' }, ] // 插入地图绑定元素 var mapEle = document.getElementById('map') if (mapEle) { mapEle.setAttribute("style", "width: 100%;height: 100%;position: absolute;left: 0;right: 0;top: 0;bottom: 0;z-index: 1;"); } else { var ele= document.createElement("div"); ele.setAttribute('id', 'map') ele.setAttribute("style", "width: 100%;height: 100%;position: absolute;left: 0;right: 0;top: 0;bottom: 0;z-index: 1;"); document.body.appendChild(ele) } // 加载脚本 function addScriptsStyles (url, type) { if (type === 'script') { var ele= document.createElement("script"); ele.setAttribute("type", "text/javascript"); ele.setAttribute("src", url); document.body.appendChild(ele) } if (type === 'style') { var ele= document.createElement("link"); ele.setAttribute("rel", "stylesheet"); ele.setAttribute("href", url); document.body.appendChild(ele) } } src.forEach(item => { addScriptsStyles(item.url, item.type) })