[OpenLayers-Dev] proposal: map.addLayer(object) as well as instance

Eric Lemoine eric.lemoine at camptocamp.com
Sun Oct 9 17:04:07 EDT 2011


On Wednesday, October 5, 2011, Jachym Cepicky <jachym.cepicky at gmail.com>
wrote:
> Hi,
>
> it probably would be nice to have ExtJS-like possibility to initialize
objects (I would start with layers).
>
> Now, you *have* to create instance of OpenLayers.Layer and than the object
can be added to map
>
> map.addLayer(new OpenLayers.Layer.WMS(name,url, params, options));
>
> What do you think about a option, that you would have to submit
object-like definition only:
>
> map addLayer({
>        CLASS_NAME: "OpenLayers.Layer.WMS",
>        name: "my name",
>        params: {
>                        layers: "0",
>                        version: "1.3.0"
>                },
>        options: {
>                        isBaseLayer: false
>                }
>        });
>
> It should not be too complicated to put such method in OpenLayers.Map
object.
>
> What do you think, shall I write some proposal-patch, or do all agree,
that it is not needed at all?

The problem is that our layer constructors don't have the same signature.
E.g. Layer.WMS receives four args, while Layer.WMTS receives one arg only.
Until we generalize 1-arg constructors I would personally not bother adding
lazy instantiation. Just my current viewport.

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20111009/e84011f7/attachment.html


More information about the Dev mailing list