Select to view content in your preferred language

How to install JavaScript API SDK as local files not via a web server

1168
2
04-16-2013 03:16 PM
DavidIp
New Contributor
I installed the JavaScript API SDK 3.3 successfully on my Python server (no Internet) by replacing [HOSTNAME_AND_PATH_TO_JSAPI] with "127.0.0.1:8001/arcgis_js_api/library/3.3/jsapi/js".

But I realized that I cannot hard code the IP address and port number in the init.js because my server is configurable based on a config file during the start-up sequence.

How can I install the SDK in such an environment? Is it true that the location.protocol is default to "http:"? Do you think making location.protocol equal to "file:" will work? And what do I enter in the [HOSTNAME_AND_PATH_TO_JSAPI]? Thanks.
0 Kudos
2 Replies
KenBurcham
Deactivated User
I would suspect it would just be an url, so using a "file" url might work, but they do have to be formatted just so...  This might help get you pointed in the right direction:

http://stackoverflow.com/q/12711584/369843

cheers!

ken.
0 Kudos
DavidIp
New Contributor
Ken,

Thank you for your response. I think I am automatically using location.protocol = file by specifying the relative path to the libraries. I got it to work in the following ways so that I would not hard my server IP address and port number.

In init.js, I did this
  .... baseUrl:(location.protocol === 'file:' ? 'http:' : location.protocol) + '//' + "../../../../arcgis_js_api/library/3.3/jsapi/js/dojo/dojo" ....
instead of
  .... baseUrl:(location.protocol === 'file:' ? 'http:' : location.protocol) + '//' + "127.0.0.1:8001/arcgis_js_api/library/3.3/jsapi/js/dojo/dojo" ....

In my JavaScript code, I did this
  <link rel="stylesheet" href="../../arcgis_js_api/library/3.3/jsapi/js/dojo/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="../../arcgis_js_api/library/3.3/jsapi/js/esri/css/esri.css">
  <script type="text/javascript" src="../../arcgis_js_api/library/3.3/jsapi/init.js"></script>
instead of
  <link rel="stylesheet" href="http://127.0.0.1:8001/arcgis_js_api/library/3.3/jsapi/js/dojo/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="http://127.0.0.1:8001/arcgis_js_api/library/3.3/jsapi/js/esri/css/esri.css">
  <script type="text/javascript" src="http://127.0.0.1:8001/arcgis_js_api/library/3.3/jsapi/init.js"></script>

For other developers who have the similar need, adjust the relative path depending on where the libraries are installed/located.