Developing with the JavaScript API

To develop with the JavaScript API on your own machine or to place applications developed with it on another server, you will need to install the proxy.

The proxy is required to start working with the JavaScript API. Simply reference the relevant JavaScript file hosted by Spectrum™ Technology Platform in your html pages, and the browser takes care of the rest. To get started developing a JavaScript API-based application:

  1. Install a web application server (for example, Tomcat) on your machine.
  2. Create a new service folder in your webapps (or equivalent) directory of your newly installed application server for your application (for example, a folder called "myapp" located in C:\apache-tomcat-7.0.39\webapps).
  3. Download the riaproxy.war file from Spectrum™ Technology Platform and copy it to your webapps (or equivalent) directory to install it.

    For information on how to download and install the proxy, and on why you must use the proxy, see Using the Proxy. For information on how to use the proxy with your web application, see Using the Proxy in your Web Application.

  4. Restart your application server.
  5. Create your application pages in the service folder that you created in the webapps (or equivalent) directory, using the functionality of the Spectrum™ Technology Platform JavaScript API.
    You can use the examples that ship with Spectrum™ Technology Platform as a starting point for your application. View the page source of the examples on your local installation at http://<server>:<port>/JavaScriptExamples/.
    1. Save the source to the myapp folder you created above.
      For example, to include searchNearest in your application, right-click in the Search Nearest content frame to display the source.
    2. Rename the .jsp file to index.htm.
    3. Edit proxy.properties to contain the following:
      trusted.base.url=https://<yourspectrumspatialserverhost_port>
      auth.type=basic 
      anonymous_username=guest 
    4. Restart Tomcat and browse to your application at http://<server>:<port>/myapp