Arcgis for javascript api的离线部署
1.下载tomcat服务器
下载链接(tomcat官网):https://tomcat.apache.org/download-90.cgi
下载之后安装
安装路径最好放在c盘
2.下载Arcgis for javascript api包
在官网下载api与sdk(先注册一个Esri的账号)
下载链接https://developers.arcgis.com/labs/?product=javascript&topic=any
帮助文档:https://developers.arcgis.com/javascript/3/jssamples/
后续的学习基本上在帮助文档上学习
下载之后随便放到那里解压
3.对解压后的api文件进行配置
打开这个HTML页面
4.打开配置arcgis for js 包的安装
注意:版本不同安装的文件名也不相同
6.根据上面给的路径信息找到第一个js文件(init.js文件)记事本打开查找[localhost…],改成这个
7.同理找到第二个js文件(dojo.js文件)一样的更改
8.将文件夹下的这个文件夹放到tomcat文件下的webapps的文件夹中
9.检查arcgsi for js api离线包是否部署完毕(该网页代码)
使用下载的api文件下的网页下面提供的前端代码
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Test Map</title>
<link rel="stylesheet" href="https://www.example.com/arcgis_js_api/library/3.29/3.29/esri/css/esri.css" />
<script src="https://www.example.com/arcgis_js_api/library/3.29/3.29/init.js"></script>
<style>
html,
body,
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
require([
"esri/map",
"esri/layers/ArcGISTiledMapServiceLayer"
],function(Map, ArcGISTiledMapServiceLayer) {
var map = new Map("map");
//If you do not have Internet access then you will need to point this url to your own locally accessible tiled service.
var tiled = new ArcGISTiledMapServiceLayer("https://services.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer");
map.addLayer(tiled);
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
更改它的链接和引入从css文件的路径
这个可以根据你放置js包的位置
例如:
C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\arcgis_js_api\\...
你可以吧webapps之前的都看成localhost:8080端口
就是:localhost:8080\arcgis_js_api\\...
10.测试,开启tomcat,用浏览器打开页面,如果出现下面的页面说明配置成功!