JavaScript原生 间接引入ArcGIS API的方法

有个需求,需要原生通过js ,统一变量URL 加载js 和css。实现如下。没有考虑其他因素。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>创建初始地图应用</title>
<style>
html,
body,
#viewDiv{
padding:0;
margin:0;
height:100%;
width:100%;
}
</style>
<link rel="stylesheet" href="http://localhost/arcgis_js_v41 ... gt%3B
<script src ="./间接引入.js"></script>
</head>
<body></body>
</html>
js代码为:
//间接引入。
var script = document.createElement("script");
script.language = "javascript";
script.src = "http://localhost/arcgis_js_v41 ... 3B%3B
document.getElementsByTagName("head")[0].appendChild(script); //将jq的js文件引入到head中

window.addEventListener("load", function(event) {
require(["esri/Map", "esri/views/MapView"], function (Map, MapView) {
var map = new Map({
basemap: "osm"
});

var view = new MapView({
container: "viewDiv",
map: map,
center: [-118.805, 34.027], // longitude, latitude
zoom: 13
});
});

});
已邀请:

许丹石

赞同来自:

css写法同理。创建link标签。

要回复问题请先登录注册