make ol.Map inherit from goog.EventTarget, and add an ol.handler.Drag

This commit is contained in:
Éric Lemoine
2012-06-28 22:33:29 +02:00
parent d8e8e55b44
commit 946cd33350
5 changed files with 91 additions and 113 deletions
+7 -7
View File
@@ -27,9 +27,9 @@ goog.inherits(ol.control.Navigation, ol.control.Control);
ol.control.Navigation.prototype.activate = function() {
var active = goog.base(this, 'activate');
if (active) {
var events = this.map_.getEvents();
events.register("drag", this.moveMap, this);
events.register("scroll", this.zoomMap, this);
var map = this.map_;
goog.events.listen(map, 'drag', this.moveMap, false, this);
goog.events.listen(map, 'scroll', this.zoomMap, false, this);
}
return active;
};
@@ -38,9 +38,9 @@ ol.control.Navigation.prototype.activate = function() {
ol.control.Navigation.prototype.deactivate = function() {
var inactive = goog.base(this, 'deactivate');
if (inactive) {
var events = this.map_.getEvents();
events.unregister("drag", this.moveMap, this);
events.unregister("scroll", this.zoomMap, this);
var map = this.map_;
goog.events.unlisten(map, 'drag', this.moveMap, false, this);
goog.events.unlisten(map, 'scroll', this.zoomMap, false, this);
}
return inactive;
};
@@ -68,4 +68,4 @@ ol.control.Navigation.prototype.zoomMap = function(evt) {
return false;
};
ol.control.addControl('navigation', ol.control.Navigation);
ol.control.addControl('navigation', ol.control.Navigation);