OpenLayers OpenLayers

Changeset 6475

Show
Ignore:
Timestamp:
03/10/08 14:23:19 (10 months ago)
Author:
euzuro
Message:

instead of directly modifyinG the popup's 'anchor' property each time the popup chanGes relative position, we instead override the calculateNewPx() function and adjust for the relative positions' offsets there. clean and simple (and took me all day on friday to fiGure it out :-P. Also in this commit, we update the offsets in the framedCloud example to be universal -- previously they were takinG into account the size of the marker in the example. also, we specify the correct information for the anchor in the sundials example. the framedpopup now works perfectly with any size or offset of anchor. one small step...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/euzuro/pop/examples/sundials.html

    r6420 r6475  
    4343        function onFeatureSelect(feature) { 
    4444            selectedFeature = feature; 
     45            var anchor = { 
     46                'size': new OpenLayers.Size(0,0),  
     47                'offset': new OpenLayers.Pixel(0,16) 
     48            }; 
    4549            popup = new OpenLayers.Popup.FramedCloud("chicken",  
    4650                                     feature.geometry.getBounds().getCenterLonLat(), 
    4751                                     new OpenLayers.Size(100,100), 
    4852                                     "<div style='font-size:.8em'>"+feature.attributes.description+"</div>", 
    49                                      {'size': new OpenLayers.Size(0,0), 'offset': new OpenLayers.Size(0,0)}, true, onPopupClose); 
    50             feature.popup = popup; 
     53                                     anchor, true, onPopupClose); 
     54           feature.popup = popup; 
    5155            map.addPopup(popup); 
    5256        } 
  • sandbox/euzuro/pop/lib/OpenLayers/Popup/Framed.js

    r6406 r6475  
    8989                        closeBoxCallback) { 
    9090 
    91         var newAnchor = null; 
     91        OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); 
     92 
    9293        if (this.fixedRelativePosition) { 
    9394            //based on our decided relativePostion, set the current padding 
    9495            // this keeps us from getting into trouble  
    95             this.padding = this.positionBlocks[this.relativePosition].padding; 
    96      
    97             newAnchor = { 
    98                 size: new OpenLayers.Size(0,0), 
    99                 offset: this.positionBlocks[this.relativePosition].offset 
    100             }; 
    101         } 
    102          
    103         var newArgs = [ 
    104             id, lonlat, size, contentHTML, newAnchor,  
    105             closeBox, closeBoxCallback 
    106         ]; 
    107         OpenLayers.Popup.Anchored.prototype.initialize.apply(this, newArgs); 
     96            this.updateRelativePosition(this.relativePosition); 
     97        } 
    10898 
    10999        this.contentDiv.style.position = "absolute"; 
     
    239229     */ 
    240230    updateRelativePosition: function(relativePosition) { 
    241         //update the anchor offset 
    242         this.anchor.offset = this.positionBlocks[relativePosition].offset; 
    243231         
    244232        //update the padding 
     
    250238            this.closeDiv.style.top = this.padding.top + "px"; 
    251239        }         
     240    }, 
     241 
     242    /**  
     243     * Method: calculateNewPx 
     244     *  
     245     * Parameters: 
     246     * px - {<OpenLayers.Pixel>} 
     247     *  
     248     * Returns: 
     249     * {<OpenLayers.Pixel>} The the new px position of the popup on the screen 
     250     *     relative to the passed-in px. 
     251     */ 
     252    calculateNewPx:function(px) { 
     253        var newPx = OpenLayers.Popup.Anchored.prototype.calculateNewPx.apply( 
     254            this, arguments 
     255        ); 
     256                                                                     
     257        newPx = newPx.offset(this.positionBlocks[this.relativePosition].offset); 
     258 
     259        return newPx;    
    252260    }, 
    253261 
  • sandbox/euzuro/pop/lib/OpenLayers/Popup/FramedCloud.js

    r6454 r6475  
    5454    positionBlocks: { 
    5555        "tl": { 
    56             'offset': new OpenLayers.Pixel(55, -10), 
     56            'offset': new OpenLayers.Pixel(61, 15), 
    5757            'padding': new OpenLayers.Bounds(15, 75, 60, 15), 
    5858            'blocks': [ 
     
    8080        }, 
    8181        "tr": { 
    82             'offset': new OpenLayers.Pixel(-35, -10), 
     82            'offset': new OpenLayers.Pixel(-45, 15), 
    8383            'padding': new OpenLayers.Bounds(15, 75, 60, 15), 
    8484            'blocks': [ 
     
    111111        }, 
    112112        "bl": { 
    113             'offset': new OpenLayers.Pixel(55, 0), 
     113            'offset': new OpenLayers.Pixel(61, -6), 
    114114            'padding': new OpenLayers.Bounds(15, 45, 60, 53), 
    115115            'blocks': [ 
     
    142142        }, 
    143143        "br": { 
    144             'offset': new OpenLayers.Pixel(-35, 0), 
     144            'offset': new OpenLayers.Pixel(-44, -6), 
    145145            'padding': new OpenLayers.Bounds(15, 45, 60, 53), 
    146146            'blocks': [