Use listen function instead of on

In #7614, the `opt_this` argument was removed from `Observable#on`, `#once` and `#un` but internal code was not adapted.
This commit is contained in:
Frederic Junod
2018-03-05 10:01:10 +01:00
parent d29fd63504
commit 235fc59c72
2 changed files with 12 additions and 5 deletions
+10 -3
View File
@@ -2,6 +2,7 @@
* @module ol/Graticule
*/
import {degreesToStringHDMS} from './coordinate.js';
import {listen, unlistenByKey} from './events.js';
import {intersects, getCenter} from './extent.js';
import GeometryLayout from './geom/GeometryLayout.js';
import LineString from './geom/LineString.js';
@@ -129,9 +130,14 @@ const Graticule = function(opt_options) {
this.map_ = null;
/**
* @type {ol.proj.Projection}
* @type {?ol.EventsKey}
* @private
*/
this.postcomposeListenerKey_ = null;
/**
* @type {ol.proj.Projection}
*/
this.projection_ = null;
/**
@@ -721,11 +727,12 @@ Graticule.prototype.updateProjectionInfo_ = function(projection) {
*/
Graticule.prototype.setMap = function(map) {
if (this.map_) {
this.map_.un(RenderEventType.POSTCOMPOSE, this.handlePostCompose_, this);
unlistenByKey(this.postcomposeListenerKey_);
this.postcomposeListenerKey_ = null;
this.map_.render();
}
if (map) {
map.on(RenderEventType.POSTCOMPOSE, this.handlePostCompose_, this);
this.postcomposeListenerKey_ = listen(map, RenderEventType.POSTCOMPOSE, this.handlePostCompose_, this);
map.render();
}
this.map_ = map;