[OpenLayers-Users] Include Data from Postgresql database in Openlayers Popup

Andrew de Klerk andrew.deklerk at gmail.com
Mon Sep 22 06:20:21 EDT 2008


Hi reena - here is an example from our application using the
"GetFeatureInfo" response from a mapserver based WMS. In your mapinit you
need to register the click event and call a function:

        map.events.register('click', map, function (e) {
            getAssetNode(e);
        });

Then your function looks something like (where mainmap is the layer name):

  function getAssetNode(e){
    mouseLoc = map.getLonLatFromPixel(e.xy);
    var url =  mainmap.getFullRequestString({
                    REQUEST: "GetFeatureInfo",
                    VERSION: "1.0.0",
                    SRS: mainmap.map.getProjection(),
                    FORMAT: "png",
                    STYLES: "",
                    EXCEPTIONS: "application/vnd.ogc.se_xml",
                    BBOX: mainmap.map.getExtent().toBBOX(),
                    X: e.xy.x,
                    Y: e.xy.y,
                    INFO_FORMAT: 'text/html',
                    QUERY_LAYERS: "Components",
                    WIDTH: mainmap.map.size.w,
                    HEIGHT: mainmap.map.size.h});
    OpenLayers.loadURL(url, '', this, setHTML);
}

That call the SetHTML function:

function setHTML(response) { 
    if (response.responseText.indexOf('no results') == -1 &&
response.statusText != "Internal Server Error") {
        //If there are any popups, then close them
        if (popup != null) {
            popup.destroy();
            popup = null;
        }
		
			popup = new
OpenLayers.Popup.FramedCloud("Installation",
	
mouseLoc,
                                            new OpenLayers.Size(100,100),
                                            response.responseText,
                                            null,
                                            true);
			popup.maxSize=new OpenLayers.Size(200,200);
			popup.minSize=new OpenLayers.Size(100,100);

            popup.setBackgroundColor("#FFFFFF");
            popup.setOpacity(0.8);
            map.addPopup(popup);
    }
}

Your mapserver map file needs a HTML template to display the appropriate
field information (in []) - i.e.
[ID]
Installation Type: [INSTALLATI]
Status: [STATUS]

Hope that helps
Andrew

-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
Behalf Of S.Reena
Sent: 22 September 2008 11:37 AM
To: users at openlayers.org
Subject: [OpenLayers-Users] Include Data from Postgresql database in
Openlayers Popup


Hello,

I want to display database query results in Openlayers Popup . I am finding
difficulty in displaying such dynamic data in pop up. Can any one help me
with sending some example or something? 

Cheers,
Reena.
-- 
View this message in context:
http://www.nabble.com/Include-Data-from-Postgresql-database-in-Openlayers-Po
pup-tp19604591p19604591.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.6.21/1667 - Release Date: 9/21/2008
10:10 AM




More information about the Users mailing list