[Users] GeoExt popup moves anchor when html is updated

David Miller teknocreator at gmail.com
Tue Apr 26 14:11:41 CEST 2011


Good morning list,

I'm hoping someone who has used the GeoExt popup can help here.  Still new
to OpenLayers and just started to worke with GeoExt/ExtJS.  I sucessfully
created an OL Framed Cloud popup to open when the mouse is clicked on the
map and display values returned from the server at that point.  The popup
first displays "Updating information..." to let the user know that the data
is being retrieved and then displays it a bit later.  The OL popup expands
upward to accommodate the changed information.  So, attempted the same thing
using GeoExt popup following the example on the page with the popup-more.js
code.  I thought I adapted the code successfully and it appeared to work.
However, after the data is retrieved, the anchor repositions down when the
text in the popup is updated and is no longer positioned where the I clicked
with the mouse.  The strange thing is when I collapse the popup and expand
it, it repositions again to where the I clicked with the mouse.  And even
stranger is that when I try to debug this using Firebug, it doesn't occur.
Here's relevant code to create and maintain the popup, most taken from the
GeoExt example code, popup-more.js:

// mouse click function for info popup

    function addToPopup(loc) {

        // create the popup if it doesn't exist
        if (!popup) {
            popup = new GeoExt.Popup({
                title: "Popup",
                maximizable: true,
                collapsible: true,
                map: map,
                anchored: true,
                html: "Updating<br/>information...",
                listeners: {
                    close: function() {
                        // closing a popup destroys it, but our reference is
truthy
                        popup = null;
                    }
                }
            });
        }
        else {
            popup.body.update("Updating<br/>information...");
        }

        // retrieve data at the point clicked

        getPopupText(loc);

       // reset the popup's location

        popup.location = loc;

        popup.doLayout();

        // since the popup is anchored, calling show will move popup to this
location
        popup.show();
      }

The getPopupText(loc) function creates the html text for display in the
popup after retrieving information from the server.  Relevant part:

              wincontent = "Station ID = " + locid + "<br/>" +
                           "<NOBR>Station Name = " + locname +
"</NOBR><br/>" +
                           "Latitude = " + loclat.toFixed(4) + "<br/>" +
                           "Longitude = " + loclon.toFixed(4) + "<br/>" +
                           "Grid Value = " + locvalue.toFixed(2) + locunit;


// set the popup text information with ExtJS

            popup.body.update(wincontent);

Sorry, I don't have a public page to view.  I saw a similar problem (if not
the same) in the list archive in June 2010 when I searched for a solution to
this problem: http://www.mail-archive.com/users@geoext.org/msg00297.html.
However, I'm unsure whether the solution solves the problem in general.  Not
sure what setting I have to ensure is set properly in order for this not to
happen.  Like I said, it doesn't in the OL poup.

Appreciate any help!

Thanks

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110426/4cc357bb/attachment.htm 


More information about the Users mailing list