Add ol.Map2D #463

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

twpayne commented Apr 4, 2013

Refs #457.

Contributor

twpayne commented Apr 4, 2013

Now in openlayers/map2d branch for experimentation.

@twpayne twpayne closed this Apr 4, 2013

Owner

elemoine commented Apr 8, 2013

I think we have three options for the ol.Map2D stuff:

  1. Inheritance - This is what Tom's PR uses, with ol.Map2D inheriting from ol.Map. This may be weird, because we use inheritance to remove functionality. It is to be noted that we use this already. See the MapQuest sources for example. These sources overload the ol.source.XYZ constructor to pre-configure a number of things.
  2. Composition - We could have ol.Map2D create an ol.Map internally, and expose functions that are proxies to ol.Map functions. This would certainly pose maintenance problems. This would also cause type-checking problems, e.g. ol.control.prototype.setMap takes an ol.Map as its argument.
  3. Factories - We could for example add an ol.map2d function returning an ol.Map. This is the option @tschaub is proposing in #501. Technically I think this is the option that makes the most sense, but it may confuse users as they may never know whether new should be used or not.
Contributor

twpayne commented Apr 8, 2013

Good summary Eric.

Note that, if we're not careful, we might run into naming collisions when using factories. For examples, ol.map is currently fine as a factory function because it is not a namespace. However, there might be problems using ol.layer, ol.source, ol.projection, etc. as these currently are namespaces. There may well be solutions to this, but we do need to explore any proposed ideas with real code to ensure that they work in practice.

@twpayne twpayne deleted the twpayne:map2d branch Apr 8, 2013

Contributor

twpayne commented Apr 8, 2013

The maps2d branch now lives in the openlayers/ol repo. Comparison here:
master...map2d

Owner

elemoine commented Apr 8, 2013

Actually, in this particular case, a factory function wouldn't work as we want to add methods (setCenter etc.) to the Map type. So it's really a new type/class that we need here. So I now think 1. Inheritance is what makes the most sense :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment