Now that you've gotten a chance to play around with Esri's JavaScript API, let's pause to discuss the big picture.
Esri's mashup architecture is largely focused on consuming services published through ArcGIS Server. Maps are the most obvious type of service and the type that we will focus on in this lesson. However, there are a number of other ArcGIS web service types that offer a great deal of potential for building rich applications, including geocoding services, geoprocessing services, image services, mobile data services, and network analysis services.
Esri makes it possible to consume their web services through the two primary architectural styles employed by web developers today: SOAP (Simple Object Access Protocol) and REST (REpresentational State Transfer). The SOAP protocol was developed by Microsoft in the 1990s and can be thought of as object-oriented programming in which the objects live on some web server and the programming code that manipulates them lives on some client machine. REST came later and has overtaken SOAP in popularity because of its ease of use. RESTful web services, as they are sometimes called, progressively expose their functionality through URLs that can be invoked almost like properties and methods. They send responses to the client applications in the form of XML or JSON.
Esri's JavaScript API uses the REST framework for working with web services published with ArcGIS Server. One important aspect of using this framework is that information on the various REST web services published through an ArcGIS Server instance can be discovered through a series of pages called the Services Directory. This directory can be viewed in a web browser using a URL of the form <server name>/arcgis/rest/services. For example, earlier in the lesson we consumed map services published through ESRI's server called 'server.arcgisonline.com'.
Let's explore that server's Services Directory.
- Go to the server.arcgisonline.com Services Directory.
The resulting page lists all of the services at the server's root directory (e.g., note the World_Street_Map and World_Topo_Map map services we used earlier). Those services having a label of MapServer are ones that can be consumed using the JavaScript API. The GlobeServer services are intended for use in ArcGlobe on the desktop or ArcGIS Explorer online.
The page also lists a number of folders (sub-directories) within the root directory. Each of these could contain a list of services itself. - Follow the World_Street_Map link to view metadata on that service.
The links along the top of the page provide a list of ways to preview the service. Clicking the ArcGIS JavaScript link will pull the service into a map as an ArcGISTiledMapServiceLayer or ArcGISDynamicMapServiceLayer, depending on how the service was published.
The Service Description can provide important information regarding the sources used in producing the service.
The Layers section lists all of the layers that are built into the service. In the case of a tiled service, this is mostly just informational since the tiles are pre-made "snapshots" of the layers stored as images. However, for dynamic services, it is possible to display only certain layers and to query individual layers.
The Spatial Reference section's purpose should be obvious. Remember that the number listed is a well-known ID that can be looked up in the documentation's coordinate system listing.
The last part of the page I want to bring to your attention is the Tile Info section. This section tells you how many and which zoom levels are covered by the service. You can even have a look at the first and last tiles for each level, if you like. Most importantly from a practical standpoint is that the existence of this section within the page tells you that you should use an ArcGISTiledMapServiceLayer to add the service to your map. Services that do not exist as cached tiles (and thus should be added using an ArcGISDynamicMapServiceLayer) will not have a Tile Info section in their metadata. I don't see any dynamic services on the server.arcgisonline.com server, so let's check a different server for that type of service. - Browse to the Services Directory for Esri's 'sampleserver1' server.
Note that the root directory contains a GeometryServer service. This type of service can be used to carry out geometric calculations such as buffering and calculating areas. - Follow the link to the Demographics folder, and from there the ESRI_Census_USA folder.
This map service lacks a Tile Info section in its metadata, so it should be added to maps as an ArcGISDynamicMapServiceLayer. The layers in this service are scale dependent. It displays states and counties at the default scale, but only shows block groups and block points if the user zooms in close enough. - Click on the coarse counties link to view metadata on that layer.
Note the Min and Max Scale values reflecting the scale-dependent nature of the map described above. Also note the list of fields in the layer's attribute table. All of these fields are queryable as we'll see later in the lesson. - Finally, return to the root (Home) directory of sampleserver1, then navigate to the Elevation folder.
This folder contains a GPServer (a geoprocessing service) called Elevation/ESRI_Elevation_World. - Click on the Elevation/ESRI_Elevation_World link and note that this service can be used to build an app that prompts the user to specify a point location and a viewing distance, and it will return the viewshed associated with those inputs.
In this section of the lesson, we saw how to explore the services published on an instance of ArcGIS Server. You might try creating a map that includes an ArcGISDynamicServiceLayer or ArcGISTiledMapServiceLayer from one of the sample servers mentioned above or maybe from a server you have at work using the Louisville land records example map from the previous page as a starting point.
In the next part of the lesson, we'll discuss these layer types in a bit more detail and then focus on another layer type that offers even greater possibilities to developers: the FeatureLayer.