Protected
disposedThe object has already been disposed.
Protected
applyProtected
Apply any properties from another object without triggering events.
The source object.
Dispatches an event and calls all listeners listening for events
of this type. The event parameter can either be a string or an
Object with a type
property.
Event object.
false
if anyone called preventDefault on the
event object or if any of the listeners returned false.
Protected
disposeProtected
onProtected
onceSets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).
Values.
Optional
silent: booleanUpdate without triggering an event.
Protected
un
Classdesc
Abstract base class; normally only used for creating subclasses and not instantiated in apps. Most non-trivial classes inherit from this.
This extends module:ol/Observable~Observable with observable properties, where each property is observable as well as the object as a whole.
Classes that inherit from this have pre-defined properties, to which you can add your owns. The pre-defined properties are listed in this documentation as 'Observable Properties', and have their own accessors; for example, module:ol/Map~Map has a
target
property, accessed withgetTarget()
and changed withsetTarget()
. Not all properties are however settable. There are also general-purpose accessorsget()
andset()
. For example,get('target')
is equivalent togetTarget()
.The
set
accessors trigger a change event, and you can monitor this by registering a listener. For example, module:ol/View~View has acenter
property, soview.on('change:center', function(evt) {...});
would call the function whenever the value of the center property changes. Within the function,evt.target
would be the view, soevt.target.getCenter()
would return the new center.You can add your own observable properties with
object.set('prop', 'value')
, and retrieve that withobject.get('prop')
. You can listen for changes on that property value withobject.on('change:prop', listener)
. You can get a list of all properties with module:ol/Object~BaseObject#getProperties.Note that the observable properties are separate from standard JS properties. You can, for example, give your map object a title with
map.title='New title'
and withmap.set('title', 'Another title')
. The first will be ahasOwnProperty
; the second will appear ingetProperties()
. Only the second is observable.Properties can be deleted by using the unset method. E.g. object.unset('foo').
Fires
ObjectEvent
Api