[OpenLayers-Dev] Layer switch depending on zoom level

Dom Lehr dominic.lehr at googlemail.com
Wed Jan 27 07:10:51 EST 2010


Hey guys,

I managed to handle the "zoom changed" event now. What I m trying to do is
to combine prerendered tiles with tiles gettin rendered "on the fly". So I
only want to rerender the tiles with a zoom greater than let s say 14. I did

>
> layerEntry0.events.on({
                      moveend: function(e) {
                        if (e.zoomChanged) {
                            var zoom = parseInt(map.zoom);
                            if(zoom >= 14){
                                   map.setBaseLayer(map.layers[1]);

                            }
                        }
                      }
                    });

The issue that I got with this solution is, that the event gets fired AFTER
the zoom changed (which makes sense, D'ooh) ... so whenever I switch the
layer, it first displays the current base layer with e.g. zoom 14, than
switches the layers and displays the tiles with zoom 14 again, using a
different base layer. Now is there a way to change the base layer BEFORE new
tiles are requested?

Thanks in advance!

Dom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20100127/beb09a91/attachment.html


More information about the Dev mailing list