Using a map for controls also.
This commit is contained in:
@@ -322,7 +322,7 @@ ol.Map.prototype.setControls = function(opt_controls) {
|
|||||||
for (var i=0, ii=opt_controls.length; i<ii; ++i) {
|
for (var i=0, ii=opt_controls.length; i<ii; ++i) {
|
||||||
control = opt_controls[i];
|
control = opt_controls[i];
|
||||||
if (!(control instanceof ol.control.Control)) {
|
if (!(control instanceof ol.control.Control)) {
|
||||||
control = new ol.control[control]();
|
control = new ol.control.CONTROL_MAP[control]();
|
||||||
}
|
}
|
||||||
control.setMap(this);
|
control.setMap(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,16 @@ goog.provide('ol.control.Control');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object}
|
* @enum {Object}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
ol.control.registry_ = {};
|
ol.control.CONTROL_MAP = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {string} name
|
||||||
* @param {Function} Control
|
* @param {Function} Control
|
||||||
* @param {string} id
|
|
||||||
*/
|
*/
|
||||||
ol.control.register = function(Control, id) {
|
ol.control.addControl = function(name, Control) {
|
||||||
ol.control.registry_[id] = Control;
|
ol.control.CONTROL_MAP = Control;
|
||||||
};
|
|
||||||
|
|
||||||
ol.control.fromRegistry = function(id) {
|
|
||||||
return ol.control.registry_[id];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,4 +46,6 @@ ol.control.Navigation.prototype.deactivate = function() {
|
|||||||
*/
|
*/
|
||||||
ol.control.Navigation.prototype.moveMap = function(evt) {
|
ol.control.Navigation.prototype.moveMap = function(evt) {
|
||||||
this.getMap().moveByPx(evt.dx, evt.dy);
|
this.getMap().moveByPx(evt.dx, evt.dy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ol.control.addControl('navigation', ol.Control.Navigation);
|
||||||
@@ -14,10 +14,10 @@ ol.event.SEQUENCE_PROVIDER_MAP = {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {Function} obj
|
* @param {Function} Sequence
|
||||||
*/
|
*/
|
||||||
ol.event.addSequenceProvider = function(name, obj) {
|
ol.event.addSequenceProvider = function(name, Sequence) {
|
||||||
ol.event.SEQUENCE_PROVIDER_MAP[name] = obj;
|
ol.event.SEQUENCE_PROVIDER_MAP[name] = Sequence;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user