[OpenLayers-Users] Strange return values for addLayer function in Map.js

Eric Lemoine eric.lemoine at camptocamp.com
Sun Nov 20 04:49:37 EST 2011


On Sat, Nov 19, 2011 at 10:15 PM, Dave Potts <dave.potts at pinan.co.uk> wrote:
> Hi List,
> In the Openlayers 2.11 release the function addLayer returns false on line
> 963 ,

Right. It returns false when the layer is already in the map. I don't think
you should rely on that. Just assume that addLayer always succeeds, making
sure at application level that layers aren't added multiple times. Another
reason not to rely on that is that this behavior has changed in the
development branch—an exception is now thrown if the layer is already in
the map.

> but at the end of function, line 999 it returns a void.
>
> How can I tell if the call to addLayer has been successful ?
>
> The same problem occurs with the function destroy values of false and void
> are returned.

Right Map.destroy returns false if the map's already destroyed. Again I'd
recommend not relying on the return value here.

--
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




-- 
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-users/attachments/20111120/153acecc/attachment.html


More information about the Users mailing list