problem description
I need to dynamically introduce a js, < script type= "text/javascript" src= " http://192.168.1.189:6789/arcgis_js_api/library/3.24/init.js"></script>
now needs to dynamically concatenate src addresses from the background, introducing easy maintenance that is not written as fixed
related codes
I tried to introduce js like this, but the console reported an error Uncaught SyntaxError: Unexpected token when calling initGisMap (). If I introduce this script map statically into head directly, it will display normally. I would like to ask whether this is correct, or are there any other ideas to achieve such a function
$(function() {
//htmldom
var theHead = document.getElementsByTagName("head").item(0);
//dom
var myScript = document.createElement("script");
myScript.src = "http://172.42.1.146:6789/arcgis_js_api/library/3.24/3.24/init.js";
myScript.type = "text/javascript";
myScript.defer = true;
myScript.onload = function() {
initGisMap()
}
theHead.appendChild(myScript);
});
function initGisMap(){
require(["esri/map",
"esri/tasks/FindTask",
"esri/tasks/FindParameters",
"extras/ClusterLayer",
"dojo/domReady!"
],
function (Map, FindTask, FindParameters, ClusterLayer) {
var map;
map = new Map("map", {
center: [112.28888, 31.38888], //
slider: false,
zoom: 0,
scale: 5000000, //
//
maxScale: 5000,
//
minScale: 3000000,
isPanArrows: true,
logo: false,
});
//http://192.168.1.189:6080/arcgis/rest/services/hubei10/MapServer GIS
var mapServiceURL = "http://172.42.1.146:6080/arcgis/rest/services/HBGSOMP/MapServer" //GIS
var layer = new esri.layers.ArcGISDynamicMapServiceLayer(mapServiceURL)
map.addLayer(layer);
map.on("load", mapLoaded);
//
map.on("mouse-wheel", function (o) {
//
var scale = Math.ceil(map.getScale())
var minScale = map.getMinScale()
var maxScale = map.getMaxScale()
if (scale == minScale) {
map.setScale(minScale)
map.setZoom(0)
map.centerAt([112.28888, 31.38888])
}
})
function mapLoaded() {
//resize
if (map && map.map) {
map.map.resize(true);
map.map.reposition();
}
// mapwindow
window.map = map
//
start()
}
this.getClusterLayer = function (data) {
return new ClusterLayer(data)
}
})