step1:1从arcgis官网上下载Arcgis api for JavaScript 4.3 https://developers.arcgis.com/javascript/latest/guide/release-notes/
ps:前提是你需要有一个esri开发者账户否则不能下载。
step2:arcgis_js_v43_api文件夹中arcgis_js_api文件拷贝到tomcat根目录的webapps目录下
step3:(最重要的一步)--编辑tomcat\webapps\arcgis_js_api\library\4.3\4.3\dojo\dojo.js和tomcat\webapps\arcgis_js_api\library\4.3\4.3\init.js这两个文件,将[HOSTNAME_AND_PATH_TO_JSAPI]改成127.0.0.1:8080/(自己本机的tomcat服务地址)。
比如当前Tomcat下你的目录结构是这样:
这种情况下用于替换的串就是:localhost:8080/arcgis_js_api/library/4.3/4.3/
同理dojo.js在tomcat下的目录结构如下图
则dojo.js中用于替换的串就是:localhost:8080/arcgis_js_api/library/4.3/4.3/dojo/
step4:web页面中引用:
<link rel="stylesheet" href="http://localhost:8080/arcgis_js_api/library/4.3/4.3/esri/css/main.css"> <script src="http://localhost:8080/arcgis_js_api/library/4.3/4.3/init.js"></script>就好了,给一个测试页面,如果可以运行出地图就说明部署好了:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"> <title>Load a basic WebMap - 4.3</title> <style> *{ padding:0; margin:0; } html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; } </style> <link rel="stylesheet" href="http://localhost:8080/arcgis_js_api/library/4.3/4.3/esri/css/main.css"> <script src="http://localhost:8080/arcgis_js_api/library/4.3/4.3/init.js"></script> <script> require([ "esri/views/MapView", "esri/Map", "dojo/domReady!" ], function( MapView, Map ) { var map = new Map({ basemap: "streets" }); var view = new MapView({ map: map, container: "viewDiv" }); }); </script> </head> <body> <div id="viewDiv"></div> </body> </html>
提示,如果运行不出来先看一下报错信息或查看一下使用的esri在线地图地图是否可以正常使用。
希望有用