版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_34719507/article/details/78562254
Windows:托管API
在Windows上安装ArcGIS API for JavaScript库
以下说明假定您将ArcGIS JavaScript API库安装在用于Windows®Server的Internet信息服务(IIS)的以下位置,https://fqdn.tld/arcgis_js_api/library/4.5/
其中fqdn.tld
是您的网站的完全限定的域名和顶级域的组合。将文件复制到Web服务器之后,您需要编辑一些文件以包含服务器的URL和目标安装目录。
如果您使用的是非Windows操作系统,请参阅在Unix / Linux / Apache上部署库的说明。
- 将
\arcgis_js_api\library
所有内容从DVD 复制到Web服务器。在这个例子中,文件被复制到:C:\Inetpub\wwwroot\arcgis_js_api\library
安装生成
C:\Inetpub\wwwroot\arcgis_js_api\library\4.5\init.js
在文本编辑器中打开并搜索文本[HOSTNAME_AND_PATH_TO_JSAPI]
,并将其替换为localhost:8080/arcgis_js_api/library/4.5/
。C:\Inetpub\wwwroot\arcgis_js_api\library\4.5\dojo\dojo.js
在文本编辑器中打开并搜索文本[HOSTNAME_AND_PATH_TO_JSAPI]
,并将其替换为localhost:8080/arcgis_js_api/library/4.5/
。
测试安装
现在,您应该可以使用以下URL从Web服务器访问ArcGIS JavaScript库:
<script src="https://localhost:8080/arcgis_js_api/library/4.5/dojo/dojo.js"></script>
测试你的安装。您可以使用以下测试代码来验证您的JSAPI库安装。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>Test Map</title>
<link rel="stylesheet" href="https://localhost:8080/arcgis_js_api/library/4.5/dijit/themes/claro/claro.css" />
<link rel="stylesheet" href="https://localhost:8080/arcgis_js_api/library/4.5/esri/css/main.css" />
<style>
html,
body,
#viewDiv {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
<script src="https://localhost:8080/arcgis_js_api/library/4.5/dojo/dojo.js"></script>
<script>
var myMap, view;
require([
"esri/Basemap",
"esri/layers/TileLayer",
"esri/Map",
"esri/views/MapView",
"dojo/domReady!"
], function (Basemap, TileLayer, Map, MapView){
// --------------------------------------------------------------------
// If you do not have public Internet access then use the Basemap class
// and point this URL to your own locally accessible cached service.
//
// Otherwise you can just use one of the named hosted ArcGIS services.
// --------------------------------------------------------------------
var layer = new TileLayer({
url: "https://localhost:8080/arcgis/rest/services/Folder/Custom_Base_Map/MapServer"
});
var customBasemap = new Basemap({
baseLayers: [layer],
title: "Custom Basemap",
id: "myBasemap"
});
myMap = new Map({
basemap: customBasemap
});
view = new MapView({
center: [-111.87, 40.57], // long, lat
container: "viewDiv",
map: myMap,
zoom: 6
});
});
</script>
</head>
<body class="claro">
<div id="viewDiv"></div>
</body>
</html>