The map object is the central component of an OpenLayers web application. It is a central place to add and remove things such as layers and controls, and bind them all together. The remaining chapters in the book will introduce you to these other things, but one of those bits is really very closely tied to the map object, and that is the view object. The view object provides the map with the information it needs to decide what location and level of detail—or zoom level—you are looking at. A view also has a projection (which we discussed in Chapter 2, Key Concepts in OpenLayers) that determines the geospatial reference system of the map.
OpenLayers currently provides a single View
class, ol.View
. This class represents a simple 2D view, which can be manipulated through three key properties: center
, resolution
, and rotation
. We will create a new instance of ol.View
in the same way that we create a map object, like the following:
var view = new ol.View(ViewOptions);
We've used...