Using a map for controls also.

This commit is contained in:
ahocevar
2012-06-21 19:33:33 +02:00
parent 9bd507e9b8
commit 188615391d
4 changed files with 12 additions and 15 deletions

View File

@@ -322,7 +322,7 @@ ol.Map.prototype.setControls = function(opt_controls) {
for (var i=0, ii=opt_controls.length; i<ii; ++i) {
control = opt_controls[i];
if (!(control instanceof ol.control.Control)) {
control = new ol.control[control]();
control = new ol.control.CONTROL_MAP[control]();
}
control.setMap(this);
}

View File

@@ -3,21 +3,16 @@ goog.provide('ol.control.Control');
/**
* @type {Object}
* @private
* @enum {Object}
*/
ol.control.registry_ = {};
ol.control.CONTROL_MAP = {};
/**
* @param {string} name
* @param {Function} Control
* @param {string} id
*/
ol.control.register = function(Control, id) {
ol.control.registry_[id] = Control;
};
ol.control.fromRegistry = function(id) {
return ol.control.registry_[id];
ol.control.addControl = function(name, Control) {
ol.control.CONTROL_MAP = Control;
};
/**

View File

@@ -46,4 +46,6 @@ ol.control.Navigation.prototype.deactivate = function() {
*/
ol.control.Navigation.prototype.moveMap = function(evt) {
this.getMap().moveByPx(evt.dx, evt.dy);
};
};
ol.control.addControl('navigation', ol.Control.Navigation);

View File

@@ -14,10 +14,10 @@ ol.event.SEQUENCE_PROVIDER_MAP = {};
/**
* @param {string} name
* @param {Function} obj
* @param {Function} Sequence
*/
ol.event.addSequenceProvider = function(name, obj) {
ol.event.SEQUENCE_PROVIDER_MAP[name] = obj;
ol.event.addSequenceProvider = function(name, Sequence) {
ol.event.SEQUENCE_PROVIDER_MAP[name] = Sequence;
};
/**