OpenLayers OpenLayers

Ticket #463 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

map.setBaseLayer is a bit funky

Reported by: tschaub Assigned to: tschaub
Priority: minor Milestone: 2.3 Release
Component: general Version: 2.3 RC1
Keywords: Cc:
State:

Description

Could be that this is intentional, but doesn't look right to me.

map.setBaseLayer assigns oldBaseLayer to this.baseLayer. Then below, this.baseLayer is set to newBaseLayer (which also sets oldBaseLayer to newBaseLayer). It could be that there is some trickery intended here, but I think it's misleading at best.

I think the real thing that is meant to be tracked is the old base layer extent. The following patch does that.

This problem creeps up when you use the layer switcher to change from MetaCarta to VirtualEarth given the following markup:

<html>
    <head>
        <title>Test</title>
        <style type="text/css">
            #map {
                width: 300px; 
                height: 300px;
                border: 1px solid gray;
            }
        </style>
       <script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js " type="text/javascript"></script>
    <script src="../lib/OpenLayers.js"></script>
    </head>
    <body>
        <div id="map"></div>
        <script defer="defer" type="text/javascript">
            var map = new OpenLayers.Map('map'); 
            var virtualearth = new OpenLayers.Layer.VirtualEarth("VirtualEarth");
            var metacarta = new OpenLayers.Layer.WMS(
                "Metacarta",
                "http://labs.metacarta.com/wms/vmap0",
                {layers: 'basic'});
            map.addLayers([metacarta, virtualearth]);
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            map.addControl(new OpenLayers.Control.OverviewMap());
            map.setCenter(new OpenLayers.LonLat(5.69, 50.85), 15);
        </script>
    </body>
</html>

Attachments

setBaseLayer.patch (1.5 kB) - added by tschaub on 01/09/07 18:03:34.
tracks old base layer extent instead of old base layer

Change History

01/09/07 18:03:34 changed by tschaub

  • attachment setBaseLayer.patch added.

tracks old base layer extent instead of old base layer

01/09/07 18:04:23 changed by tschaub

  • keywords set to review.

happy to commit if reviewed

01/20/07 10:40:18 changed by crschmidt

  • keywords changed from review to commit.

I agree that this looks unintentional. Please go ahead to commit: tests pass, and the logic behind the change is sound.

01/20/07 12:05:36 changed by tschaub

  • keywords changed from commit to pullup.

applied w r2167

01/22/07 22:14:50 changed by crschmidt

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.