OpenLayers OpenLayers

Changeset 6326

Show
Ignore:
Timestamp:
02/19/08 16:14:59 (11 months ago)
Author:
enjahova
Message:

Updated and fixed a bug that would give an error in IE

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/enjahova/openlayers/lib/OpenLayers/Control/OverviewMap.js

    r6232 r6326  
    3838     * class name olControlOverviewMapElement) may have padding or other style 
    3939     * attributes added via CSS. 
    40          size: new OpenLayers.Size(190,90)...leave blank so overview map width / height can be overwritten in css 
    41     */ 
    42     size: new OpenLayers.Size(), 
     40     */ 
     41    size: new OpenLayers.Size(180, 90), 
    4342 
    4443    /** 
     
    10099     
    101100    /** 
    102      * Property: dragHandler 
    103      * {<OpenLayers.Handler.Drag>} A handler for dragging the extent rectangle. 
    104      */ 
    105     dragHandler: null, 
     101     * Property: handlers 
     102     * {Object} 
     103     */ 
     104    handlers: null, 
    106105 
    107106    /** 
     
    116115    initialize: function(options) { 
    117116        this.layers = []; 
     117        this.handlers = {}; 
    118118        OpenLayers.Control.prototype.initialize.apply(this, [options]); 
    119119    }, 
     
    127127            return; 
    128128        } 
    129         this.dragHandler.destroy(); 
    130         this.clickHandler.destroy(); 
     129        this.handlers.click.destroy(); 
    131130 
    132131        this.mapDiv.removeChild(this.extentRectangle); 
     
    156155        } 
    157156         
    158         this.map.events.unregister('moveend', this, this.update); 
     157    this.map.events.unregister('moveend', this, this.update); 
    159158        this.map.events.unregister("changebaselayer", this,  
    160159                                    this.baseLayerDraw); 
     
    200199 
    201200        this.div.appendChild(this.element); 
    202  
    203         this.map.events.register('moveend', this, this.update); 
    204201 
    205202        // Optionally add min/max buttons if the control will go in the 
     
    261258            this.update(); 
    262259        } 
     260         
     261        this.map.events.register('moveend', this, this.update); 
     262 
    263263        return this.div; 
    264264    }, 
     
    281281     */ 
    282282    rectDrag: function(px) { 
    283         var deltaX = this.dragHandler.last.x - px.x; 
    284         var deltaY = this.dragHandler.last.y - px.y; 
     283        var deltaX = this.handlers.drag.last.x - px.x; 
     284        var deltaY = this.handlers.drag.last.y - px.y; 
    285285        if(deltaX != 0 || deltaY != 0) { 
    286286            var rectTop = this.rectPxBounds.top; 
     
    435435        // create the overview map 
    436436        var options = OpenLayers.Util.extend( 
    437                         {controls: [], maxResolution: 'auto'}, this.mapOptions); 
     437                        {controls: [], maxResolution: 'auto',  
     438                         fallThrough: false}, this.mapOptions); 
    438439        this.ovmap = new OpenLayers.Map(this.mapDiv, options); 
     440         
     441        // prevent ovmap from being destroyed when the page unloads, because 
     442        // the OverviewMap control has to do this (and does it). 
     443        OpenLayers.Event.stopObserving(window, 'unload', this.ovmap.unloadDestroy); 
     444         
    439445        this.ovmap.addLayers(this.layers); 
    440446        this.ovmap.zoomToMaxExtent(); 
     
    451457        this.hComp = (this.hComp) ? this.hComp : 2; 
    452458 
    453         this.dragHandler = new OpenLayers.Handler.Drag( 
     459        this.handlers.drag = new OpenLayers.Handler.Drag( 
    454460            this, {move: this.rectDrag, done: this.updateMapToRect}, 
    455461            {map: this.ovmap} 
    456462        ); 
    457         this.clickHandler = new OpenLayers.Handler.Click( 
     463        this.handlers.click = new OpenLayers.Handler.Click( 
    458464            this, { 
    459465                "click": this.mapDivClick 
     
    465471            } 
    466472        ); 
    467         this.clickHandler.activate(); 
     473        this.handlers.click.activate(); 
    468474         
    469475        this.rectEvents = new OpenLayers.Events(this, this.extentRectangle, 
    470476                                                null, true); 
    471477        this.rectEvents.register("mouseover", this, function(e) { 
    472             if(!this.dragHandler.active && !this.map.dragging) { 
    473                 // this click handler de/activation can be removed when 
    474                 // ticket #1247 is addressed 
    475                 this.clickHandler.deactivate(); 
    476                 this.dragHandler.activate(); 
    477                 this.clickHandler.activate(); 
     478            if(!this.handlers.drag.active && !this.map.dragging) { 
     479                this.handlers.drag.activate(); 
    478480            } 
    479481        }); 
    480482        this.rectEvents.register("mouseout", this, function(e) { 
    481             if(!this.dragHandler.dragging) { 
    482                 this.dragHandler.deactivate(); 
     483            if(!this.handlers.drag.dragging) { 
     484                this.handlers.drag.deactivate(); 
    483485            } 
    484486        }); 
     
    495497        if(this.map.units != 'degrees') { 
    496498            if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { 
    497                 alert('The overview map only works when it is in the same projection as the main map'); 
     499                alert(OpenLayers.i18n("sameProjection")); 
    498500            } 
    499501        } 
     
    510512    updateMapToRect: function() { 
    511513        var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds); 
    512         this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom); 
     514        this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom); 
    513515    }, 
    514516