1、下载API并解压到tomcat
下载之前需要登陆arcgis官网的账号,如果没有那就注册一下,不过需要翻墙,然后按照步骤填写就可以了。
下载地址
https://developers.arcgis.com/downloads/apis-and-sdks?product=javascript
存放的目录
image.png
2、修改init.js和dojo.js访问路径
init.js存放路径
image.pngdojo.js存放路径
image.png
进入对应文件,搜索PATH。如下图。
20191223165114212.png
把中括号的内容替换为你存放api的的路径(到达版本号的那层)。千万记得别把后面的dojo给删了。
http://192.168.1.243:8008/arcgis_js_v414_api/arcgis_js_api/library/4.14/
image.png
3、启动、测试
启动tomcat,然后访问
http://192.168.1.243:8008/arcgis_js_v414_api/arcgis_js_api/library/4.14/init.js
如果能访问到那就成功了!
4、应用到项目中
methods: {
createMap() {
const options = {
// url: "https://js.arcgis.com/4.14/",
url: "http://192.168.1.243:8008/arcgis_js_v414_api/arcgis_js_api/library/4.14/init.js",
css: true,
insertCssBefore: 'style'
};
loadModules(["esri/Map", 'esri/views/MapView', 'esri/WebMap'], options)
.then(([Map, MapView, WebMap]) => {
var map = new Map({
basemap: "streets"
});
var view = new MapView({
container: "viewDiv", // Reference to the scene div created in step 5
map: map, // Reference to the map object created before the scene
zoom: 4, // Sets zoom level based on level of detail (LOD)
center: [15, 65] // Sets center point of view using longitude,latitude
});
});
}
}
结果如下
image.png
网友评论