下载api地址:官方地址
3系列和4系列步骤相同,本文以3系列为例
1.下载api,并解压到IIS或者tomcat中
如图所示:

2.导航至如下位置:

用vscode或其他能编辑js文件的软件,打开init.js文件和dojo文件夹下的dojo.js文件,并搜索PATH,找到如下位置:

将baseUrl改为http://localhost/3.31/dojo

同样,dojo.js文件也是这样修改
3.验证API是否能访问的到
验证方法一:将上述修改的地址中,http://localhost/3.31/dojo后面加上/dojo.js,即:http://localhost/3.31/dojo/dojo.js在浏览器中访问,出现如下界面

即证明路径没有问题
验证方法二:
3.31版
将下面代码中的api地址换成你本地的,看是否能出来地图,因为我的api部署在了100.92的机器上,故此处写ip
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>FeatureLayer</title>
<link rel="stylesheet" href="http://192.168.100.92/3.31/esri/css/esri.css">
<script src="http://192.168.100.92/3.31/init.js"></script>
<style>
html,
body,
#map {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/map",
"esri/layers/FeatureLayer",
"dojo/domReady!"
],
function (
Map,
FeatureLayer
) {
var map = new Map("map", {
// basemap: "osm",
center: [-82.44109, 35.6122],
zoom: 17
});
/****************************************************************
* Add feature layer - A FeatureLayer at minimum should point
* to a URL to a feature service or point to a feature collection
* object.
***************************************************************/
// Carbon storage of trees in Warren Wilson College.
var featureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0");
map.addLayer(featureLayer);
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>
4.13版,同上,详见代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Intro to MapView - Create a 2D map - 4.14</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="http://192.168.100.92/4.14/esri/themes/light/main.css" />
<script src="http://192.168.100.92/4.14/init.js"></script>
<script>
require(["esri/Map", "esri/views/MapView"], function (Map, MapView) {
var map = new Map({
basemap: "osm"
});
var view = new MapView({
container: "viewDiv",
map: map,
zoom: 4,
center: [15, 65] // longitude, latitude
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
3地图效果

4地图效果

本文详细介绍如何将ArcGIS API下载并部署至本地IIS或Tomcat服务器,通过修改baseUrl配置,确保API可被正常访问及使用。文章提供两种验证方法,确保API正确部署,并附带示例代码展示如何在不同版本中应用本地API。
5186

被折叠的 条评论
为什么被折叠?



