[MapQuery] Re: Return value of Layer.remove()
Volker Mische
volker.mische at gmail.com
Tue Feb 28 13:23:20 EST 2012
On 02/27/2012 12:47 AM, Volker Mische wrote:
> Hi all,
>
> I currently work on the event handling a bit and I stumbled upon the
> Layer.remove() function. According to the docs, it returns the ID of the
> layer (the implementation doesn't, but that would be easy to fix).
>
> Though I don't think this makes much sense. But what are the
> alternatives? For the "removelayer" event, I've gone for including the
> just removed layer in the event. This is also what OpenLayers does. It
> makes sense, as you can now use its data to so some cleanup in your
> application.
>
> A good return value is a harder problem. Returning the removed layer
> doesn't make much sense, as we want some kind of chaining. It would be
> odd to have a chain with a non-attached layer.
>
> Another possible value would be the Map object, so you can keep the
> chain and e.g. add a new layer.
>
> What do you think?
>
> Cheers,
> Volker
After a quick discussion with Steven on the IRC channel, here's what we
concluded.
Normally, if you remove a layer, you don't need the return value. But in
what cases do you need one? For example if you want to have a popup
saying that layer xyz was removed. But those things should be done
asynchronously. This is what the "layerremoved" event is for, which will
include the removed layer.
Hence we thought returning the map instead is a easy to remember
behaviour. The mnemonic will be "if you remove something, the upper
level will be returned". For layers it's the map, for features (which I
code atm) it will be the layer.
Any comments? :)
Cheers,
Volker
More information about the MapQuery
mailing list