[OpenLayers-Trac] Re: [OpenLayers] #3168: FramedCloudPopup has offset

OpenLayers trac-20090302 at openlayers.org
Fri Mar 25 20:05:53 EDT 2011


#3168: FramedCloudPopup has offset
-----------------------+----------------------------------------------------
 Reporter:  pebXX2346  |       Owner:  euzuro      
     Type:  bug        |      Status:  new         
 Priority:  minor      |   Milestone:  2.11 Release
Component:  Popup      |     Version:  2.10        
 Keywords:  position   |       State:              
-----------------------+----------------------------------------------------

Comment(by pebXX2346):

 Right, but has still an offset! [[BR]]
 if the popup is on top it is 'anchored' at top of the marker.
 Also there is some px distance. The popup isn't anchored at lonlat,
 but at the markers image 'frame'?
 On [http://www.openstreetmap.de/] they are perfect.

 '''Note'''[[BR]]
 if one want to use the current release (2.10) one may 'patch' it by
 calling following code after including OpenLayers:

 {{{
 <script type="text/javascript">
 // fix 2.10
 OpenLayers.Popup.Anchored.prototype.calculateNewPx=function(px) {
         var newPx = px.offset(this.anchor.offset);

         //use contentSize if size is not already set
         var size = this.size || this.contentSize;

         var top = (this.relativePosition.charAt(0) == 't');
         newPx.y += (top) ? -size.h : this.anchor.size.h;

         var left = (this.relativePosition.charAt(1) == 'l');
         newPx.x += (left) ? -size.w : this.anchor.size.w;

         return newPx;
     };

 </script>

 }}}

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3168#comment:3>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list