OpenLayers OpenLayers

Ticket #328 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

Layer.clone() copies map div dependent resolution settings

Reported by: euzuro Assigned to: euzuro
Priority: major Milestone: 2.2 Release
Component: Layer Version: SVN
Keywords: Cc:
State:

Description (Last modified by euzuro)

Working in sandbox here branched from r1655

Problem:

Imagine a page with two map divs:

    <div id="map1" style="height:500px;width:500px"></div>
    <div id="map2" style="height:100px;width:100px"></div>

Now imagine we initialize the maps as follows:

    var options = { 'maxResolution': 'auto' };
    var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                  "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'},
                  options); 

    var bigMap = new OpenLayers.Map("map1");
    bigMap.addLayer(wms);
  
    var smallMap = new OpenLayers.Map("map2");
    smallMap.addLayer(wms.clone());

When we call bigMap.addLayer(wms);, OpenLayers.Layer.initResolutions() is called, and will set the wms.resolutions[] array to values based on the 500x500px mapdiv to which it is being added.

When we then call smallMap.addLayer(wms.clone());, OpenLayers.Layer.initResolutions() will be called again, but this time the wms.resolutions[] array will already be populated (from the previous call), and therefore the layer will not recalculate the resolutions array to be based on the new map's smaller 100x100px div.

Solution:

What we will do is the following

  • Instead of OpenLayers.Layer.initResolutions() basing its calculations on the properties set directly on the Layer object itself (ie. this.scales, this.resolutions, etc) it will now call those on the layer's options parameter (ie. this.options.scales, this.options.resolutions, etc)

Attachments

layerclone.patch (10.5 kB) - added by euzuro on 10/06/06 18:26:37.
suggested patch to fix layer.clone() including updated and new tests
layerclone.2.patch (10.5 kB) - added by euzuro on 10/06/06 18:28:24.
updated…

Change History

10/06/06 16:24:23 changed by euzuro

  • status changed from new to assigned.
  • description changed.

10/06/06 18:26:37 changed by euzuro

  • attachment layerclone.patch added.

suggested patch to fix layer.clone() including updated and new tests

10/06/06 18:28:24 changed by euzuro

  • attachment layerclone.2.patch added.

updated...

10/06/06 18:36:24 changed by euzuro

patch added... please review this ticket

10/06/06 18:58:35 changed by crschmidt

  • status changed from assigned to closed.
  • resolution set to fixed.

Reviewed. Looks good, all tests pass, solves bug. Committed, r1662 .