HOW TO

Install the JavaScript API for use with ArcGIS for Server

Last Published: April 25, 2020

Summary

When using ArcGIS for Server in an isolated or secure environment, it may not be possible to access the hosted Esri JavaScript API libraries. This article provides a walkthrough for installing a local copy of the JavaScript API and configuring it for use with ArcGIS for Server.

Procedure

Note:
This document assumes that Microsoft IIS is being used as the web server. If using a different program, some steps may not apply or may be different based on that configuration. Please consult that software’s documentation if needed.

Download and install the JavaScript API

  1. Navigate to the ArcGIS API for JavaScript page.
  2. Sign in using Esri Global Account credentials.
  3. Under the ArcGIS Web SDKs (Download for Hosting Locally) section, download both the API and Documentation.
Note:
At time of publishing the current JSAPI release is 3.16 and all subsequent folder paths include this information. If using an alternate version adjust the paths accordingly.
  1. Extract both files to a temporary location such as the following:
C:\Users\<user>\Downloads\arcgis_js_v316_api\arcgis_js_api
C:\Users\<user>\Downloads\arcgis_js_v316_sdk\arcgis_js_api
  1. Create a new folder in the IIS root virtual directory called arcgis_js_api as shown below:
C:\inetpub\wwwroot\arcgis_js_api
  1. Copy the extracted library and sdk subfolders from their temporary locations into the newly created arcgis_js_api folder:
C:\inetpub\wwwroot\arcgis_js_api\library
C:\inetpub\wwwroot\arcgis_js_api\sdk

Modify JavaScript files

Note:
Please note in the following two steps, do not include 'http://' with the fully qualified host name as this is already defined in the two files.
  1. Open the following file in a text editor:
C:\inetpub\wwwroot\arcgis_js_api\library\3.16\3.16\init.js
  1. Search for the text [HOSTNAME_AND_PATH_TO_JSAPI] and replace this text with:
<myhost.example.com>/arcgis_js_api/library/3.16/3.16/
  1. Open the following file in a text editor:
C:\Inetpub\wwwroot\arcgis_js_api\library\3.16\3.16\dojo\dojo.js
  1. Search for the text [HOSTNAME_AND_PATH_TO_JSAPI] and replace this text with:
<myhost.example.com>/arcgis_js_api/library/3.16/3.16/
  Edit ArcGIS services
  1. In a web browser on the server, navigate to the following location:
http://localhost:6080/arcgis/admin/system/handlers/rest/servicesdirectory
  1. Log in with administrator credentials.
  2. Copy or take a screenshot of the current Services Directory settings in case it is necessary to revert to the default settings.
  3. Click Edit to modify settings.
  4. Replace each of the following fields with the path to the local installation of the JavaScript API using the fully qualified host name in place of the following examples:
Javascript API URL:
http://myhost.example.com/arcgis_js_api/library/3.16/3.16/init.js
Javascript API SDK URL:
http://myhost.example.com/arcgis_js_api/sdk/
Javascript API CSS URL:
http://myhost.example.com/arcgis_js_api/library/3.16/3.16compact/dijit/themes/tundra/tundra.css
Javascript API CSS2 URL:
http://myhost.example.com/arcgis_js_api/library/3.16/3.16/esri/css/esri.css
Note:
If the server is configured to use HTTPS only, modify the examples above to use HTTPS instead of HTTP as the URL connection.
  1. Clear the browser cache to complete installation.
Note:
To confirm that ArcGIS for Server is using the correct settings for the JavaScript API, open a web debugging program and preview a map service using the ArcGIS JavaScript viewer from the Services Directory (REST). If configured correctly, the viewer should load successfully and all URLs listed in the web debugger are from the local web server and not from 'serverapi.arcgisonline.com'

Article ID:000011974

Software:
  • ArcGIS Server

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic