OpenLayers OpenLayers

Ticket #884: OverviewMap.js.diff

File OverviewMap.js.diff, 2.3 kB (added by ahocevar, 1 year ago)

I found out that the problem is due to the theme css not being completely loaded when wComp and hComp are calculated. This new patch removes the firstRun logic, and does a setTimeout loop instead until values for wComp and hComp are returned. I do not know if using setTimeout is an appropriate way according to OpenLayers design, but it works.

  • /mnt/d/eclipse/workspace/openlayers/lib/OpenLayers/Control/OverviewMap.js

    old new  
    510510        this.ovmap = new OpenLayers.Map(this.mapDiv.id, options); 
    511511        this.ovmap.addLayers(this.layers); 
    512512        this.ovmap.zoomToMaxExtent(); 
    513         // check extent rectangle border width 
     513        this.calculateBorderCompensation(); 
     514    }, 
     515     
     516    /** 
     517     * Method: calculateBorderCompensation 
     518     * Check extent rectangle border width and calculate the 
     519     * compensation values for width/height 
     520     */ 
     521    calculateBorderCompensation: function() { 
    514522        this.wComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle, 
    515523                                               'border-left-width')) + 
    516524                     parseInt(OpenLayers.Element.getStyle(this.extentRectangle, 
     
    515523                                               'border-left-width')) + 
    516524                     parseInt(OpenLayers.Element.getStyle(this.extentRectangle, 
    517525                                               'border-right-width')); 
    518         this.wComp = (this.wComp) ? this.wComp : 2
     526        this.wComp = (this.wComp) ? this.wComp : 0
    519527        this.hComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle, 
    520528                                               'border-top-width')) + 
    521529                     parseInt(OpenLayers.Element.getStyle(this.extentRectangle, 
     
    520528                                               'border-top-width')) + 
    521529                     parseInt(OpenLayers.Element.getStyle(this.extentRectangle, 
    522530                                               'border-bottom-width')); 
    523         this.hComp = (this.hComp) ? this.hComp : 2; 
    524     }, 
     531        this.hComp = (this.hComp) ? this.hComp : 0; 
    525532         
     533        if (this.hComp == 0 && this.wComp == 0) { 
     534            window.setTimeout((function() { 
     535                    this.calculateBorderCompensation(); 
     536                }).bind(this), 100); 
     537        } else { 
     538            this.updateOverview(); 
     539        } 
     540    }, 
     541 
    526542    /** 
    527543     * Method: updateRectToMap 
    528544     * Updates the extent rectangle position and size to match the map extent