OpenLayers Cookbook
上QQ阅读APP看书,第一时间看更新

What you need for this book

The fact that OpenLayers is a JavaScript library, which must be integrated within HTML pages, implies that the user must be familiarized with these technologies.

To run the recipes you need to place the code bundle within a HTTP server that serves the pages. All library dependencies required by the recipes code, such as OpenLayers or Dojo toolkit (http://dojotoolkit.org), are included in the bundle itself.

Some recipes request data from PHP scripts included in the source bundle. The function of these scripts is to generate some random data to later integrate within the map. To run these recipes properly the reader needs a HTTP server with PHP support.

Solutions such as XAMPP (http://www.apachefriends.org/en/xampp.html) or Bitnami Stacks (http://bitnami.org/stack/lampstack) are an easy way to install the required stack.

For better user experience, we have created a main application that allows the desired recipe to run and show its source code. Supposing the reader has installed and configured a local web server, and the bundle code is copied within the HTTP server root content folder in the openlayers-cookbook folder, the user can run the main application by accessing the http://localhost/openlayers-cookbook/index.html URL in the browser.

We have made use of the Dojo toolkit in many of the recipes because it allows us to create rich components such as sliders or toggle buttons. Dojo's JavaScript library and CSS files are included in the index.html file, so the HTML recipe files do not have to include them. If the reader plans to run the recipes as standalone web pages, he/she will need to include Dojo's JavaScript library and CSS files in the recipe file, otherwise the recipe will not work properly.