The instructions below assume that you are installing the ArcGIS API for JavaScript library in the following location
https://www.example.com/arcgis_js_api/library/3.35/
(/var/www/html/arcgis_js_api/library/3.35/
)
on an Apache HTTP Server, where www.example.com
is the combination of the fully qualified domain name and
top level domain of your web site.
If you are using a Windows operating system, please follow the link for instructions on deploying the library on Internet Information Services (IIS) for Windows® Server.
The ArcGIS API for JavaScript library can be copied in its entirety to your web server directory
(/var/www/html/arcgis_js_api/library/3.35/
). Copy /arcgis_js_api/library/3.35/,
and all its contents from the ArcGIS API for JavaScript download to your web server. In this example the files are copied
to: /var/www/html/arcgis_js_api/library/3.35/
.
After copying the files to your web server, you will need to edit some files to specify the baseUrl
(www.example.com/arcgis_js_api/library/3.35/
) for the default Dojo configuration.
The default hosting configuration for both the ArcGIS API for JavaScript library and documentation is HTTPS
.
HTTPS
requires your web server to use a web server certificate.MIME
types registered.extension | MIME/type | Description |
---|---|---|
.ttf | application/octet-stream | True Type Fonts |
.wasm | application/wasm | WebAssembly |
.woff | application/font-woff | Web Open Font Format |
.woff2 | application/font-woff2 | Web Open Font Format 2.0 |
ArcGIS API for JavaScript contains two builds -- a normal build and a compact build. The compact build removes the Dojo Dijit dependency and minimizes the non-essential ArcGIS API for JavaScript classes. Please see the documentation for more details.
Your directions may differ depending on your server configuration or Web server, but the process is the same.
Note: if your server doesn't support https, also change the https
in the replaced string below to http
.
/var/www/html/arcgis_js_api/library/3.35/3.35/init.js
in a text editor and search for the text "https://[HOSTNAME_AND_PATH_TO_JSAPI]/dojo"
, and replace this text with "https://www.example.com/arcgis_js_api/library/3.35/3.35/dojo"
/var/www/html/arcgis_js_api/library/3.35/3.35/dojo/dojo.js
in a text editor and search for the text "https://[HOSTNAME_AND_PATH_TO_JSAPI]/dojo"
, and replace this text with "https://www.example.com/arcgis_js_api/library/3.35/3.35/dojo"
/var/www/html/arcgis_js_api/library/3.35/3.35compact/init.js
in a text editor and search for the text "https://[HOSTNAME_AND_PATH_TO_JSAPI]dojo"
, and replace this text with "https://www.example.com/arcgis_js_api/library/3.35/3.35compact/dojo"
/var/www/html/arcgis_js_api/library/3.35/3.35compact/dojo/dojo.js
in a text editor and search for the text "https://[HOSTNAME_AND_PATH_TO_JSAPI]dojo"
, and replace this text with "https://www.example.com/arcgis_js_api/library/3.35/3.35compact/dojo"
Now you should be able to access the ArcGIS API for JavaScript library from your web server using the following URL(s):
<script src="https://www.example.com/arcgis_js_api/library/3.35/3.35/init.js">
<script src="https://www.example.com/arcgis_js_api/library/3.35/3.35compact/init.js">
Test your install. You can use the following test code to validate your ArcGIS API for JavaScript library installation.
<!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.35/3.35/esri/css/esri.css" />
<script src="https://www.example.com/arcgis_js_api/library/3.35/3.35/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>
The Services Directory allows you to view Map and Image services using the JavaScript API. Set the following values in the rest-config.properties file to use the local install:
#JS API URLs
jsapi.arcgis=https://www.example.com/arcgis_js_api/library/3.35/3.35/
jsapi.arcgis.sdk=https://www.example.com/arcgis_js_sdk/sdk/
jsapi.arcgis.css=https://www.example.com/arcgis_js_api/library/3.35/3.35/dijit/themes/tundra/tundra.css
Finally make sure the import statement for the esri.css
stylesheet is in the <ArcGIS Server Install Location>ArcGIS\Server\framework\runtime\tomcat\webapps\arcgis#rest\www\client\mapserver\mapserverJSAPI.jsp
file.
<style>
@import "<%=jsapiArcgisCssUrl%>";
@import "<%=cpath%>/static/jsapi.css";
@import "<%=jsapiArcgisUrl%>/js/esri/css/esri.css";
</style>
View the Configuring the Rest API help topic for more details.
Note: While not recommended, it is possible to host the ArcGIS API for JavaScript library usinghttp
. Thedojo.js
andinit.js
files would need modification to updatehttps
tohttp
.
Before:baseUrl:"https://www.example.com/arcgis_js_api/library/3.35/3.35/dojo"
After:baseUrl:"http://www.example.com/arcgis_js_api/library/3.35/3.35/dojo"