Files
openlayers/src/ol/control/defaults.js
2013-03-06 20:46:52 +01:00

43 lines
1.2 KiB
JavaScript

goog.provide('ol.control.defaults');
goog.require('goog.array');
goog.require('ol.control.Attribution');
goog.require('ol.control.Zoom');
/**
* @param {ol.control.DefaultsOptions=} opt_options Options.
* @param {Array.<ol.control.Control>=} opt_controls Additional controls.
* @return {Array.<ol.control.Control>} Controls.
*/
ol.control.defaults = function(opt_options, opt_controls) {
var options = goog.isDef(opt_options) ? opt_options : {};
/** @type {Array.<ol.control.Control>} */
var controls = [];
var attributionControl = goog.isDef(options.attribution) ?
options.attribution : true;
if (attributionControl) {
var attributionControlOptions = goog.isDef(options.attributionOptions) ?
options.attributionOptions : undefined;
controls.push(new ol.control.Attribution(attributionControlOptions));
}
var zoomControl = goog.isDef(options.zoom) ?
options.zoom : true;
if (zoomControl) {
var zoomControlOptions = goog.isDef(options.zoomControlOptions) ?
options.zoomControlOptions : undefined;
controls.push(new ol.control.Zoom(zoomControlOptions));
}
if (goog.isDef(opt_controls)) {
goog.array.extend(controls, opt_controls);
}
return controls;
};