installing ESRI JavaScript API locally

10997
4
09-04-2014 04:00 AM
MatthewTucknott
New Contributor III

Hi,

I have a machine that has ArcGIS Server which is not connected to the internet.I want to use the JavaSCript API and so have followed the instructions for installing it locall

The instructions are...

Install notes for the ArcGIS API for JavaScript™

Installing the ArcGIS API for JavaScript™ Library

The instructions below assume that you are installing the ArcGIS JavaScript API library in the following location on an IIS Web Server, "http://<myserver>/arcgis_js_api/library/3.10/" where <myserver> is the domain name of your Web site. After copying files to your Web server, you will need to edit some files to include the URL to the server and directory that you are planning to install to.

For instructions on deploying the library on Linux please go here.

Copy \arcgis_js_api\library and all its contents from the DVD to your Web server. In this example the files are copied to

C:\Inetpub\wwwroot\arcgis_js_api\library

Install the Normal or Compact Build

ArcGIS JSAPI 3.10 contains two builds--a normal build and a compact build. The compact build removes the Dojo Dijit dependancy and minimizes the non-essential ArcGIS JSAPI 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.

Configuration options for normal build:

  1. Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.10\3.10\init.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with "<myserver>/arcgis_js_api/library/3.10/3.10/"
  2. Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.10\3.10\js\dojo\dojo\dojo.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with "<myserver>/arcgis_js_api/library/3.10/3.10/"

  Configuration options for compact build:  

  1. Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.10\3.10compact\init.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace each instance of this text with "<myserver>/arcgis_js_api/library/3.10/3.10compact/"
  2. Open C:\Inetpub\wwwroot\arcgis_js_api\library\3.10\3.10compact\js\dojo\dojo\dojo.js in a text editor and search for the text '[HOSTNAME_AND_PATH_TO_JSAPI]', and replace this text with "<myserver>/arcgis_js_api/library/3.10/3.10compact/"

Test the Install

  Access the ArcGIS JavaScript library from your Web server using the following URL(s): 

http://<myserver>/arcgis_js_api/library/3.10/3.10/init.js

and

http://<myserver>/arcgis_js_api/library/3.10/3.10compact/init.js

Test your install. You can use the following test code to validate your JSAPI library install.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Simple Map</title>
    <link rel="stylesheet" type="text/css" href="http://<myserver>/arcgis_js_api/library/3.10/3.10/js/dojo/dijit/themes/tundra/tundra.css"/>
    <link rel="stylesheet" type="text/css" href="http://<myserver>/arcgis_js_api/library/3.10/3.10/js/esri/css/esri.css" />
    <script type="text/javascript" src="http://<myserver>/arcgis_js_api/library/3.10/3.10/init.js"></script>
 
    <script type="text/javascript">
 
      dojo.require("esri.map");
 
      function init() {
        var myMap = new esri.Map("mapDiv");
        //note that if you do not have public Internet access then you will need to point this url to your own locally accessible cached service.
 
        var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer");
 
        myMap.addLayer(myTiledMapServiceLayer);
 
      }
 
      dojo.addOnLoad(init);
 
    </script>
 
  </head>
 
  <body class="tundra">
    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
 
  </body>
 
</html>
 

Change the ArcGIS Services Directory "View In JavaScript" URL.

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=http:///arcgis_js_api/library/3.10/3.10/js/
jsapi.arcgis.sdk=http:///arcgis_js_sdk/sdk/
jsapi.arcgis.css=http:///arcgis_js_api/library/3.10/3.10/js/dojo/dijit/themes/tundra/tundra.css
 

Finally make sure the import statement for the esri.css stylesheet is in the ArcGIS\Server\framework\runtime\tomcat\webapps\arcgis#rest\www\client\mapserver\mapserverJSAPI.jsp file.

<style type="text/css">
@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.

Installing the ArcGIS JavaScript API SDK

The ArcGIS JavaScript API SDK can be copied in its entirety to your Web server directory. This SDK is equivalent to the version found on the ArcGIS for Developers JavaScript site.

  1. Copy \arcgis_js_api\sdk and all its contents from the DVD to your Web server. In this example the files are copied to
C:\Inetpub\wwwroot\arcgis_js_api\sdk
  1. The start page is "index.html". If you chose to do so, you can rename this page.

However this does not seem to work.

Has anyone done this?

Many thanks

Tuckers

0 Kudos
4 Replies
by Anonymous User
Not applicable

Hi Tuckers,

First thing, is to test the download API source. Have you tested successfully the "Test the install" part?

To change the ArcGIS Services Directories, if you have version 10.2.1 or above, access the REST Admin page. Then go to system/handlers/rest//servicesdirectory/edit. There is where you can find the directories to be changed. There is no rest-config.properties with these versions.

Regards,

Richard

0 Kudos
RiyasDeen
Occasional Contributor III

Hi Matthew,

Assuming you have followed the steps. Since your server is not connected to internet you will not be able to access the map service "http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer"

provided in the test html page from your server.

Did you try accessing the test html page from a PC connected to internet?

0 Kudos
JeffJacobson
Occasional Contributor III
0 Kudos
MatthewTucknott
New Contributor III

Hi,

I have now got this working. It was schoolboy error. I have put <localhost>\URL when it should have been localhost\URL

Dooh.

Thanks for all the replies.

Its good to see that this forum is quite active 🙂

0 Kudos