Table of Contents for
Mastering OpenLayers 3

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Mastering OpenLayers 3 by Gábor Farkas Published by Packt Publishing, 2016
  1. Cover
  2. Table of Contents
  3. Mastering OpenLayers 3
  4. Mastering OpenLayers 3
  5. Credits
  6. About the Author
  7. About the Reviewer
  8. www.PacktPub.com
  9. Preface
  10. What you need for this book
  11. Who this book is for
  12. Conventions
  13. Reader feedback
  14. Customer support
  15. 1. Creating Simple Maps with OpenLayers 3
  16. Structure of OpenLayers 3
  17. Building the layout
  18. Using the API documentation
  19. Debugging the code
  20. Summary
  21. 2. Applying Custom Styles
  22. Customizing the default appearance
  23. Styling vector layers
  24. Customizing the appearance with JavaScript
  25. Creating a WebGIS client layout
  26. Summary
  27. 3. Working with Layers
  28. Building a layer tree
  29. Adding layers dynamically
  30. Adding vector layers with the File API
  31. Adding vector layers with a library
  32. Removing layers dynamically
  33. Changing layer attributes
  34. Changing the layer order with the Drag and Drop API
  35. Clearing the message bar
  36. Summary
  37. 4. Using Vector Data
  38. Accessing attributes
  39. Setting attributes
  40. Validating attributes
  41. Creating thematic layers
  42. Saving vector data
  43. Saving with WFS-T
  44. Modifying the geometry
  45. Summary
  46. 5. Creating Responsive Applications with Interactions and Controls
  47. Building the toolbar
  48. Mapping interactions to controls
  49. Building a set of feature selection controls
  50. Adding new vector layers
  51. Building a set of drawing tools
  52. Modifying and snapping to features
  53. Creating new interactions
  54. Building a measuring control
  55. Summary
  56. 6. Controlling the Map – View and Projection
  57. Customizing a view
  58. Constraining a view
  59. Creating a navigation history
  60. Working with extents
  61. Rotating a view
  62. Changing the map's projection
  63. Creating custom animations
  64. Summary
  65. 7. Mastering Renderers
  66. Using different renderers
  67. Creating a WebGL map
  68. Drawing lines and polygons with WebGL
  69. Blending layers
  70. Clipping layers
  71. Exporting a map
  72. Creating a raster calculator
  73. Creating a convolution matrix
  74. Clipping a layer with WebGL
  75. Summary
  76. 8. OpenLayers 3 for Mobile
  77. Responsive styling with CSS
  78. Generating geocaches
  79. Adding device-dependent controls
  80. Vectorizing the mobile version
  81. Making the mobile application interactive
  82. Summary
  83. 9. Tools of the Trade – Integrating Third-Party Applications
  84. Exporting a QGIS project
  85. Importing shapefiles
  86. Spatial analysis with Turf
  87. Spatial analysis with JSTS
  88. 3D rendering with Cesium
  89. Summary
  90. 10. Compiling Custom Builds with Closure
  91. Configuring Node JS
  92. Compiling OpenLayers 3
  93. Bundling an application with OpenLayers 3
  94. Extending OpenLayers 3
  95. Creating rich documentation with JSDoc
  96. Summary
  97. Index

Configuring Node JS

As a first task, we will need a copy of Node JS running on our system. We can get this piece of software in different ways on different systems. This book covers the installation process on Windows and Linux systems. After the installation, everything will work similarly from the command line or terminal.

Tip

If you use the Mac OS X, there are great tutorials to install Node JS on the Web. The http://coolestguidesontheplanet.com/installing-node-js-on-osx-10-10-yosemite/ website shows you how to install it with a precompiled binary (do not be misled by the title; it's the one for El Capitan), while http://sourabhbajaj.com/mac-setup/Node.js/README.html shows you how to install it using brew.

Installing Node JS on Windows

To get Node JS on Windows, we have to download the installer from its home page. First, we navigate to https://nodejs.org/en/, where the site tries to detect our system configuration and automatically offers a version to download. In most cases, this version is the appropriate one.

Tip

If the site misinterprets your system, navigate to the download's site where you can choose the right installer.

Next, we download the installer and run it. Then, the installation wizard leads us through the installation process. We can leave every option in their default values. After the installation is finished, we get some shortcuts for different purposes:

Installing Node JS on Windows

From the available shortcuts, we will need the command prompt (Node.js command prompt) as we will need to start various JavaScript programs. When we start a program, we get a default command line with the message: the command line is configured to work with Node JS. The only thing left to do is navigate to the folder containing the source code of OpenLayers 3. We can easily do this with the cd command and a relative path from the current directory.

Tip

If you have your source code on a different partition, you have to change the current partition first. You can do this by simply typing in the letter of the partition. For example, if you have your source code on partition D and you are in partition C, just type D: in the command prompt before changing the current directory.

Installing Node JS on Linux

In Linux, we can easily install Node JS if we have a distribution with a package management system. The only restriction is that we must have superuser privileges to install new packages. Therefore, we have to change to a superuser with su or prepend sudo to the following commands. For Debian-based distributions (such as Ubuntu), we have to run the following command in the terminal:

apt-get install node

In systems based on Fedora and Red Hat, we can use the yum package manager to achieve the same results:

yum install node

Tip

Most of the common distributions have their own package management systems. For example, Arch Linux has pacman. If your distribution does not have one, you have to build Node JS from its source code. You can download the source code from the Node JS download page.

If we used su to switch to the superuser, we switch back with the exit or logout commands, and navigate to the source code's directory using cd.

Resolving dependencies

The installation process of Node JS gave us two programs for our use: node and npm. npm stands for Node Package Manager, and we will use it to install every dependency of OpenLayers 3. npm can be used to install packages globally or only for a single project. We will use the latter option as it is a cleaner solution for our case. From now on, every step will be almost identical on different operating systems.

Note

When we say almost identical, we mean that on Windows, you have to replace every forward slash (/) representing a folder delimiter with a backward slash (\). You only have to do this for command-line commands. In configuration files, you have to use a forward slash as usual.

To resolve the dependencies of OpenLayers 3, we only have to type the following command in the terminal from the directory of the source code (src/ol3-3.11.1):

npm install

If we wait for the command to finish, we will notice that there are two new folders in the directory, called node_modules and build. The node_modules folder contains every node package used by OpenLayers 3 on compilation. The other folder contains some external JavaScript libraries, which are bundled with OpenLayers 3.