[OpenLayers-Users] GetFeatureInfo in a FrameCloud popup

Eric Lemoine eric.c2c at gmail.com
Sun Jun 8 10:18:16 EDT 2008


On Sun, Jun 8, 2008 at 3:36 PM, Alessio Di Lorenzo
<alessio.dilorenzo at gmail.com> wrote:
> Hi Eric
>
>> You probably mean: <http://openlayers.org/dev/examples/getfeatureinfo.html>.
>>
>
> Yes... sorry for the wrong link
>
>>
>>> Is it possible?
>>>
>>
>> Sure, just create a framedcloud popup in the OpenLayers.loadURL() callback.
>>
>
> Thank you very much. I'll try as soon as!
> Could you show me a quick example of the code I need to get it working?
> I'll appreciate a lot :)

The code should look like this (untested):

    var createPopup = function(response) {
        // this refers to the event object
        var lonlat = map.getLonLatFromViewPortPx(this.xy);
        var popup = new OpenLayers.Popup.FramedCloud(
 	                "__popup",    // popup id
 	                lonlat,            // OpenLayers.LonLat object
 	                null,               // popup is autosized
 	                response,      // html string
	                null,               // no anchor
 	                true                // close button
        );
        map.addPopup(popup, true /* exclusive */);
    };
    map.events.register('click', map, function (e) {
            var url =  wms.getFullRequestString({
                            REQUEST: "GetFeatureInfo",
                            EXCEPTIONS: "application/vnd.ogc.se_xml",
                            BBOX: wms.map.getExtent().toBBOX(),
                            X: e.xy.x,
                            Y: e.xy.y,
                            INFO_FORMAT: 'text/html',
                            QUERY_LAYERS: wms.params.LAYERS,
                            WIDTH: wms.map.size.w,
                            HEIGHT: wms.map.size.h
            });
            OpenLayers.loadURL(url, '', e, createPopup);
            OpenLayers.Event.stop(e);
    });

Hope this helps,

--
Eric



More information about the Users mailing list