Using Open Layers With Arc Gis Server Rest Api Dev Summit

This presentation was made in the 2009 ESRI Developer Summit by James Fee. It shows how to use OL with ArcGIS Server both consuming map and geoprocessing services. Share/Save/Bookmark


Caveats when using OpenLayers consuming WMS services

OpenLayers is great API to build client side javascript map applications. It is now in the 2.7 release version an it is more than two years old. These two things makes it a good choice to build web map applications, since it has a thriving community of users and lots of success-cases alredy in use in many different environments. It also offers the possibility to add map services from different sources, such as Yahoo Maps, Microsoft Live Maps, Google Maps (of course) and, WMS servers. And here is when problems may arise if you don't have a clear idea about how WMS services work.

As every web map developer should know, WMS is an OpenGeospatial Consortium specification and according to the official definition, it allows to make requests to a WMS server and the "response to the request is one or more geo-registered map images (returned as JPEG, PNG, etc) that can be displayed in a browser application". In my opinion, here comes the confusion. A newcomer developer with a background in the usage of Google Maps may think that "onr or more" map images is something similar to a tiled service. That is not the case. Each WMS request produces just only one image (typically). Not a tiled set of images corresponding to the request. Actually, OGC is now in the process of discussion to provide an OGC standard specification to retrieve WMS tiled images. By the way, a little piece of technology patriotism here. One of the two organizations working on it is the CREAF, from the Autonomous University of Barcelona and the other being CubeWrex. WMS specification was first intented as a request - response protocol, before Google and other vendor started to provide fast tiled maps. Now, almost every customer or geoservices provider wants to add fast tiled maps to their applications.

What happen when you add a WMS service in OpenLayers? By default, OL internally prepares the request to make a sort of tiled requests to the server (you can easily see how it works using Firebug). This could be very dangeruous in terms of performance for your Map server application. Imagine 10 concurrent requests, divided into 10 tiles each one. We were demanding to the server to process 100 request at the very same moment. Obviously, the time needed to proccess the last ones would be considerable. Well, it also depends on your hardware and balancing architecture, but it is not reasonable to demand this kind of processing power when you can choose more efficient alternatives. Those alternatives could be:
  • use a single request option when adding WMS layers
    singleTile: true
  • use tiled services coming from TileCache or GeoWebCache
  • wait until the official WMS-cached specification is available (joking)
All of this is of special importance specially when consuming external or not owned WMS services, because it can heavily affects your map performance. Therefore, if you see out there a fast compelling application using just only WMS layers, it is almost sure that they are using any kind of tiling process in the background (unless they have a cloud computing farm of servers).

Side note: OL can now leverage the new ArcGIS Server REST API (clap, clap, clap)

Final question: Is it always mandatory to provide map services as WMS? Is WMS now the best protocol to deliver fast map applications?