[OpenLayers-Users] Problem with a customized pop-up positioning

D. Stroeer dennis.stroeer at geosysnet.de
Tue Jul 24 03:43:10 PDT 2012


Hello everyone,

I have a problem with a customized pop-up positioning. I pursue the
following goals:
- the user clicks on a marker of a wfs point feature.
- the map gets centered at the position of this feature
- the center of my pop-up appears centered above the position of this
feature:
- the popup size is fixed with "width:482px; height: 310px;"

the result would look like this (X is the marker of the wfs point feature):

###############map#################
#                                                                  #
#                 #####popup######                   #
#                 #                          #                   #
#                 #            X            #                   #
#                 #                          #                   #
#                 ###############                   #
#                                                                  #
###################################


I wrote a function that gets the position of the selected feature and
calculates the new position

function popupPosition(pos) {

    lon = pos.lon;
    lat = pos.lat;

    lonPixTmp = map.getPixelFromLonLat(pos).x;
    latPixTmp = map.getPixelFromLonLat(pos).y;

    lonPix = lonPixTmp + 241;
    latPix = latPixTmp + 155;

    popPosTmp = new OpenLayers.Pixel(lonPix, latPix);
    popPos = map.getLonLatFromPixel(popPosTmp);

    return popPos;

 };


The popup gets created a this new position:

popup = new OpenLayers.Popup.Anchored("info",
                        popPos,
                        new OpenLayers.Size(450,300),
                        html,
                        null, true, onPopupClose);


This solution works in most cases!
But if the position of the feature is close to the left border of my map,
the map gets centered at the right position and the popup appears at the
right height, but appears at the wrong horizontal position. And if the
position of the feature is close to the upper border of my map, the map gets
centered at the right position and the popup appears at the right horizontal
position, but at the wrong vertical position.

Is there anybody with an idea to fix this problem? I'm grateful for any
hint!

Cheers,
D. Stroeer




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Problem-with-a-customized-pop-up-positioning-tp4990350.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list