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

Key-Value Observing with the Object class


OpenLayers' Object class inherits from Observable and implements a software pattern called Key-Value Observing (KVO). With KVO, an object representing some data maintains a list of other objects that wish to observe it. When the data value changes, the observers are notified automatically.

The following methods are available in all OpenLayers classes, which inherit from ol.Object. Note that the Object class also contains all the methods provided by the Observable class even though they are not listed here:

Method

Parameters

Description

bindTo(key,target, targetKey)

  • keystring

  • targetol.Object

  • targetKeystring

This method is used to add an observer to a property on the object. The key parameter specifies which property of the object is being bound. The target parameter specifies the object to which the property is bound. The targetKey parameter specifies the property of the target object to which the property of this object is being...