OpenLayers is, at a fundamental level, not doing anything that is conceptually too hard to grasp. It gets map data from a server, and puts them together. From a technical level, however, there is a lot of work going on, and it might seem magical how it all works together so well.
Fortunately, there are many tools to dispel any potential magical thinking we might have and show us how OpenLayers is working behind the scenes. Google Chrome Developer Tools, the included debugger in Google Chrome browser, is one such great tool. Speeding up development time, viewing network communication, and squashing bugs are just a few things that Chrome Developer Tools, and other web development tools, do that make them hard to live without.
To really use OpenLayers effectively and to its full potential, we need to understand how it works. In this appendix, we'll try our best to do just that, by using web development tools to examine OpenLayers' inner workings. By doing so, we'll accomplish two things. First, we'll become familiar with these tools, which will significantly help us when developing our maps. Secondly, and more importantly for now, we'll gain a better understanding of how OpenLayers works.
We'll do another tour about plugins and functions that can improve your experience in Chrome Developers Tools and can help you develop your OpenLayers debugging skills. To finish, the last topic will be how to work with other browsers when debugging. You may not be aware, but Google Chrome and its Developers Tools is around one-third of the browser market.
In this chapter, we'll cover the following topics:
Chrome Developer Tools, also called Chrome DevTools, is the built-in debugger included in Google Chrome browser, a free cross-platform browser. Other modern- and standards-based browsers, such as Mozilla's Firefox, Apple's Safari, Opera, and Microsoft Internet Explorer (8+) also work well for debugging web-based applications and sites.
Chrome DevTools and other web development tools make the web development process much easier and quicker. What do we mean by this? With these tools, we can change anything on our site on the fly without editing or saving any files. We can type in JavaScript code with a command-line interface and execute it immediately. We can view all the requests that our web page sends to servers, along with the server's reply. For example, if our map isn't able to get back map images from the server, we can examine the requests our page is making and find out if we have any typos or haven't set up our map layer properly.
Using these tools makes it a lot easier to develop not only an OpenLayers mapping application, but any web application, and makes it easier to fix any bugs we encounter in the process. The choice to use Google Chrome as the first tool for debugging instead of other debuggers is motivated by its large support for mobile testing, the best built-in tools for debugging at the time of this writing, its support for all OS (Windows, Mac, Linux) and some others features. We'll focus mainly on Google Chrome in this chapter and refer back to it throughout the book. Other tools such as Mozilla's Firefox, Internet Explorer (8+), and Apple's Safari's developer tools work just as well (although some functionality may vary).
To discover this tool, firstly, Google Chrome browser needs to be installed.
So, go to its dedicated download area at http://www.google.com/chrome/ and install it. Depending of your OS, the format for installing the software will be an .exe, a .dmg, a .deb or an .rpm file.