Initial port of Control.js and Navigation.js.

This also adds an Events instance to the map, so the Navigation control can register events on the map.

Tests still missing.
This commit is contained in:
ahocevar
2012-06-20 23:21:44 +02:00
parent 4ea2fe3701
commit 6ddda53a70
7 changed files with 203 additions and 720 deletions

View File

@@ -38,6 +38,8 @@ ol.map = function(opt_arg){
var resolutions;
/** @type {Array|undefined} */
var layers;
/** @type {Array|undefined} */
var controls;
if (arguments.length == 1) {
if (opt_arg instanceof ol.Map) {
@@ -53,6 +55,7 @@ ol.map = function(opt_arg){
maxRes = opt_arg['maxRes'];
resolutions = opt_arg['resolutions'];
layers = opt_arg['layers'];
controls = opt_arg['controls'];
}
else {
throw new Error('ol.map');
@@ -87,6 +90,9 @@ ol.map = function(opt_arg){
if (goog.isDef(layers)) {
map.setLayers(layers);
}
if (goog.isDef(controls)) {
map.setControls(controls);
}
return map;
};
@@ -189,6 +195,20 @@ ol.Map.prototype.layers = function(opt_arg) {
}
};
/**
* @export
* @param {Array=} opt_arg
* @returns {ol.Map|Array|undefined} Map center.
*/
ol.Map.prototype.controls = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
this.setControls(opt_arg);
return this;
} else {
return this.getControls();
}
};
/**
* @export
* @param {Array=} opt_arg