[OpenLayers-Users] Wrong pop-up position (falling off the map)

Emmanuele Sordini emmanuele.sordini at gmail.com
Tue Jul 28 10:59:13 EDT 2009

Dear all,
I have a world map with some fixed markers on it; clicking on each
marker will open an AnchoredBubble popup with some content in it. So
far I've let OL decide where to put the popup, just by doing something
like this:

myPopup =
    new OpenLayers.Popup.AnchoredBubble("Project",				
                                                new OpenLayers.LonLat(lon, lat),
                                                new OpenLayers.Size(340, 250),

Trouble is, that in some cases the popup is placed in the wrong
position, thus resulting in a good portion of it ending up off the
viewport bounds (and therefore, invisible). This seems to be happening
a little more often in the vertical side, i.e. with markers whose
position is closer to either the top or the bottom of the viewport.

What could I do to fix this problem, i.e. by having OL choose the
right coordinates, or by figuring them out myself? Of course the first
approach would be preferable, but I'm determined to get rid of this
annoying bug.

Other useful info: OL 2.8, viewport around 800 x 600 pixels with
multiple layers (popup, Google maps) and a 340 x 250-pixel popup.

Any help on this issue will be highly valued.

Thanks in advance

More information about the Users mailing list