Or we could add a lower level function that doesn't change the internal state of gaLayers.

I created an issue for these problems: https://github.com/geoadmin/mf-geoadmin3/issues/628.