Browse files

Use an array to specify additional controls

  • Loading branch information...
1 parent 23f0097 commit 363cb87e1a510258fefc7bd3b6f97be459241153 @twpayne committed Mar 6, 2013
Showing with 8 additions and 8 deletions.
  1. +3 −3 examples/side-by-side.js
  2. +5 −5 src/ol/control/defaults.js
View
6 examples/side-by-side.js
@@ -34,7 +34,7 @@ var domMousePosition = new ol.control.MousePosition({
undefinedHTML: ' '
});
var domMap = new ol.Map({
- controls: ol.control.defaults({}, domMousePosition),
+ controls: ol.control.defaults({}, [domMousePosition]),
layers: new ol.Collection([layer]),
renderer: ol.RendererHint.DOM,
target: 'domMap',
@@ -48,7 +48,7 @@ var webglMousePosition = new ol.control.MousePosition({
undefinedHTML: ' '
});
var webglMap = new ol.Map({
- controls: ol.control.defaults({}, webglMousePosition),
+ controls: ol.control.defaults({}, [webglMousePosition]),
renderer: ol.RendererHint.WEBGL,
target: 'webglMap'
});
@@ -65,7 +65,7 @@ var canvasMousePosition = new ol.control.MousePosition({
undefinedHtml: ' '
});
var canvasMap = new ol.Map({
- controls: ol.control.defaults({}, canvasMousePosition),
+ controls: ol.control.defaults({}, [canvasMousePosition]),
renderer: ol.RendererHint.CANVAS,
target: 'canvasMap'
});
View
10 src/ol/control/defaults.js
@@ -1,16 +1,17 @@
goog.provide('ol.control.defaults');
+goog.require('goog.array');
goog.require('ol.control.Attribution');
goog.require('ol.control.ScaleLine');
goog.require('ol.control.Zoom');
/**
* @param {ol.control.DefaultsOptions=} opt_options Options.
- * @param {...ol.control.Control} var_args Further controls.
+ * @param {Array.<ol.control.Control>=} opt_controls Additional controls.
* @return {Array.<ol.control.Control>} Controls.
*/
-ol.control.defaults = function(opt_options, var_args) {
+ol.control.defaults = function(opt_options, opt_controls) {
var options = goog.isDef(opt_options) ? opt_options : {};
@@ -41,9 +42,8 @@ ol.control.defaults = function(opt_options, var_args) {
controls.push(new ol.control.Zoom(zoomControlOptions));
}
- var i;
- for (i = 1; i < arguments.length; ++i) {
- controls.push(arguments[i]);
+ if (goog.isDef(opt_controls)) {
+ goog.array.extend(controls, opt_controls);
}
return controls;

0 comments on commit 363cb87

Please sign in to comment.