Book Image

OpenLayers 3: Beginner's Guide

By : Thomas Gratier, Paul Spencer, Erik Hazzard
Book Image

OpenLayers 3: Beginner's Guide

By: Thomas Gratier, Paul Spencer, Erik Hazzard

Overview of this book

<p>This book is a practical, hands-on guide that provides you with all the information you need to get started with mapping using the OpenLayers 3 library.</p> <p>The book starts off by showing you how to create a simple map. Through the course of the book, we will review each component needed to make a map in OpenLayers 3, and you will end up with a full-fledged web map application. You will learn the key role of each OpenLayers 3 component in making a map, and important mapping principles such as projections and layers. You will create your own data files and connect to backend servers for mapping. A key part of this book will also be dedicated to building a mapping application for mobile devices and its specific components.</p>
Table of Contents (22 chapters)
OpenLayers 3 Beginner's Guide
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Appendix B. More details on Closure Tools and Code Optimization Techniques

Closure Tools are a set of utilities used for web development. It is mainly supported by Google, but is open source under the Apache License Version 2.0, a well-established permissive license. The name Closure Tools hides under it a lot of subtools, which will make your life as an apprentice developer easier. It includes a JavaScript optimizer, a JavaScript library, a templating library, a style checker and style fixer, and at last, a stylesheet language. Just to illustrate how powerful this set can be, think that most Google JavaScript applications, such as Gmail or Google Maps, use these components.

Why are we introducing you to these tools?

The OpenLayers 3 library itself depends on the Closure Library, the JavaScript library attached to Closure Tools. Its main goal is to leverage cross-browser support. You also know you can write your application in pure JavaScript.

However, you can also consider Closure for advanced uses like creating your own component such as controls and buttons with special behavior inherited from an existing OpenLayers component. You will also get some useful UI components. It is also a good toolset to achieve better file compression when you want an efficient web mapping application, using the Closure Compiler, another utility from the Closure Tools bundle.

We will not review all Closure Tools but only the most useful. Specifically, we will cover the following topics:

  • Understanding the Closure Tools concepts

  • How to use the Closure Library and a small review of the main components' families

  • Why Closure Compiler is different from others compiler tools

  • How to use it with Closure Library and with other JavaScript libraries. Application of Closure Tools in OpenLayers for improving our way of developing web-mapping applications

  • The use of the already hidden workflow in OpenLayers code that relies on Closure Tools

  • Best practices for creating readable code and how to detect and fix errors using both Closure style checker and style fixer