OpenLayers OpenLayers

Changeset 2088

Show
Ignore:
Timestamp:
12/22/06 12:35:34 (2 years ago)
Author:
crschmidt
Message:

This is the outside_viewport patch from tschaub for #446:
http://trac.openlayers.org/attachment/ticket/446/outside_viewport.patch

The large diff is because I am suffering under constraints of a bad working
environment. I hate newlines! This patch closes #446.

Files:

Legend:

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

    r1721 r2088  
    3131         
    3232    /** 
     33     * The overvew map size in pixels.  Note that this is the size of the map 
     34     * itself - the element that contains the map (class name 
     35     * olControlOverviewMapElement) may have padding or other style attributes 
     36     * added via CSS. 
     37     * @type OpenLayers.Size 
     38     */ 
     39    size: new OpenLayers.Size(180, 90), 
     40 
     41    /** 
    3342     * Ordered list of layers in the overview map.  If none are sent at 
    3443     * construction, then the default below is used. 
     
    5362 
    5463    /** 
     64     * An object containing any non-default properties to be sent to the 
     65     * overview map's map constructor.  These should include any non-default 
     66     * options that the main map was constructed with. 
     67     * @type: Object 
     68     */ 
     69    mapOptions: {}, 
     70 
     71    /** 
    5572     * @constructor 
    5673     * @param {Object} options Hashtable of options to set on the overview map 
     
    6582    draw: function() { 
    6683        OpenLayers.Control.prototype.draw.apply(this, arguments); 
    67  
    6884        if(!(this.layers.length > 0)) { 
    6985            if (this.map.baseLayer) { 
     
    8298 
    8399        this.mapDiv = document.createElement('div'); 
    84         this.mapDiv.style.width = '180px'; 
    85         this.mapDiv.style.height = '90px'; 
     100        this.mapDiv.style.width = this.size.w + 'px'; 
     101        this.mapDiv.style.height = this.size.h + 'px'; 
    86102        this.mapDiv.style.position = 'relative'; 
    87103        this.mapDiv.style.overflow = 'hidden'; 
     
    100116 
    101117        this.div.appendChild(this.element); 
    102         this.div.className = 'olControlOverviewMapContainer'; 
    103118 
    104119        this.map.events.register('moveend', this, this.update); 
     
    131146        this.mapDivEvents.register('click', this, this.mapDivClick); 
    132147 
    133         // There should be an option to place the control outside of the 
    134         // map viewport.  This would make these buttons optional. 
    135         var imgLocation = OpenLayers.Util.getImagesLocation(); 
    136         // maximize button div 
    137         var img = imgLocation + 'layer-switcher-maximize.png'; 
    138         this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv( 
    139                                     'olControlOverviewMapMaximizeButton',  
    140                                     null,  
    141                                     new OpenLayers.Size(18,18),  
    142                                     img,  
    143                                     'absolute'); 
    144         this.maximizeDiv.style.display = 'none'; 
    145         this.maximizeDiv.className = 'olControlOverviewMapMaximizeButton'; 
    146         OpenLayers.Event.observe(this.maximizeDiv,  
    147                       'click',  
    148                       this.maximizeControl.bindAsEventListener(this)); 
    149         this.div.appendChild(this.maximizeDiv); 
    150  
    151         // minimize button div 
    152         var img = imgLocation + 'layer-switcher-minimize.png'; 
    153         this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv( 
    154                                     'OpenLayers_Control_minimizeDiv',  
    155                                     null,  
    156                                     new OpenLayers.Size(18,18),  
    157                                     img,  
    158                                     'absolute'); 
    159         this.minimizeDiv.style.display = 'none'; 
    160         this.minimizeDiv.className = 'olControlOverviewMapMinimizeButton'; 
    161         OpenLayers.Event.observe(this.minimizeDiv,  
    162                       'click',  
    163                       this.minimizeControl.bindAsEventListener(this)); 
    164  
    165         this.div.appendChild(this.minimizeDiv); 
    166          
    167         this.minimizeControl(); 
     148        // Optionally add min/max buttons if the control will go in the 
     149        // map viewport. 
     150        if(!this.div.parentNode  || 
     151           (this.div.parentNode.className == 'olMapViewport')) { 
     152            this.div.className = 'olControlOverviewMapContainer'; 
     153            var imgLocation = OpenLayers.Util.getImagesLocation(); 
     154            // maximize button div 
     155            var img = imgLocation + 'layer-switcher-maximize.png'; 
     156            this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv( 
     157                                        'olControlOverviewMapMaximizeButton',  
     158                                        null,  
     159                                        new OpenLayers.Size(18,18),  
     160                                        img,  
     161                                        'absolute'); 
     162            this.maximizeDiv.style.display = 'none'; 
     163            this.maximizeDiv.className = 'olControlOverviewMapMaximizeButton'; 
     164            OpenLayers.Event.observe(this.maximizeDiv,  
     165                          'click',  
     166                          this.maximizeControl.bindAsEventListener(this)); 
     167            this.div.appendChild(this.maximizeDiv); 
     168     
     169            // minimize button div 
     170            var img = imgLocation + 'layer-switcher-minimize.png'; 
     171            this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv( 
     172                                        'OpenLayers_Control_minimizeDiv',  
     173                                        null,  
     174                                        new OpenLayers.Size(18,18),  
     175                                        img,  
     176                                        'absolute'); 
     177            this.minimizeDiv.style.display = 'none'; 
     178            this.minimizeDiv.className = 'olControlOverviewMapMinimizeButton'; 
     179            OpenLayers.Event.observe(this.minimizeDiv,  
     180                          'click',  
     181                          this.minimizeControl.bindAsEventListener(this)); 
     182     
     183            this.div.appendChild(this.minimizeDiv); 
     184             
     185            this.minimizeControl(); 
     186        } else { 
     187            // show the overview map 
     188            this.element.style.display = ''; 
     189        } 
    168190 
    169191        return this.div; 
     
    370392    createMap: function() { 
    371393        // create the overview map 
    372         this.ovmap = new OpenLayers.Map(this.mapDiv.id, {controls: [], maxResolution: 'auto'}); 
     394        var options = OpenLayers.Util.extend( 
     395                        {controls: [], maxResolution: 'auto'}, this.mapOptions); 
     396        this.ovmap = new OpenLayers.Map(this.mapDiv.id, options); 
    373397        this.ovmap.addLayers(this.layers); 
    374398        this.ovmap.zoomToMaxExtent(); 
     
    390414     */ 
    391415    updateRectToMap: function() { 
     416        // The base layer for overview map needs to be in the same projection 
     417        // as the base layer for the main map.  This should be made more robust. 
    392418        if(this.map.units != 'degrees') { 
    393             if(this.map.projection != this.ovmap.map.projection) { 
     419            if(this.map.getProjection() != this.ovmap.getProjection()) { 
    394420                alert('The overview map only works when it is in the same projection as the main map'); 
    395421            }