openlayers/ol3 — pull request #175 by elemoine (2013-02-04 09:23:34+00:00)
Title: Simplify control architecture

Currently the map has a collection of controls, and provides a `getControls` method for accessing the controls collection. For example adding a control to the map is done as follows:

```
map.getControls().push(aControl);
```

When a control is added to a map's controls collection the map calls `setMap(this)` on that control. This gives the control a reference to the map, and the opportunity to add HTML markup to the map's "overlay container".

With the current design we can easily end up with inconsistent states:

- If we "relocate" a control by calling `setMap(map2)` then we end up with the following state: map1 includes the control, while the control has a reference to map2 (and is effectively rendered in map2).

- If we "relocate" a control by calling `map2.getControls().push(aControl)` we also end up with an inconsistent state: map1 and map2 both include the control, while the control has a reference to map2.

I'm suggesting to fix this by simplifying things a bit. I don't think we need maps to reference controls. For now controls can just be objects with setMap functions. This PR implements this. Also, as a convenience, the map constructor can create controls, based on some options passed to the map constructor.

Please review.