From 8adcc155fbb0fc56b0e7f934f4823eb19c468a71 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 2 Mar 2010 21:39:23 +0000 Subject: [PATCH] Added Map::addControls method. Yet another quality patch from Marc, with everything done right plus unit tests. p=marcjansen, r=me (closes #2399) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10085 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 24 ++++++++++++++++++++++++ tests/Map.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index a9952cb36a..dd734e0a79 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1167,6 +1167,8 @@ OpenLayers.Map = OpenLayers.Class({ /** * APIMethod: addControl + * Add the passed over control to the map. Optionally + * position the control at the given pixel. * * Parameters: * control - {} @@ -1176,6 +1178,28 @@ OpenLayers.Map = OpenLayers.Class({ this.controls.push(control); this.addControlToMap(control, px); }, + + /** + * APIMethod: addControls + * Add all of the passed over controls to the map. + * You can pass over an optional second array + * with pixel-objects to position the controls. + * The indices of the two arrays should match and + * you can add null as pixel for those controls + * you want to be autopositioned. + * + * Parameters: + * controls - {Array()} + * pixels - {Array()} + */ + addControls: function (controls, pixels) { + var pxs = (arguments.length === 1) ? [] : pixels; + for (var i=0, len=controls.length; i