[OpenLayers-Users] Popup only on WMS layer object

Ravi Pavuluri ravitheja at ymail.com
Wed Aug 3 08:36:47 EDT 2011


Michal,

You may try checking if "event.text" has your data before adding a popup. There may be a better way.

-Ravi.



________________________________
From: michsred <michsred at gmail.com>
To: users at openlayers.org
Sent: Wednesday, August 3, 2011 7:22 AM
Subject: [OpenLayers-Users] Popup only on WMS layer object

Hi list,

is it possible to construct GetFeatureInfo machanism with popup which will
be active only on objects (points, lines, polygons) from WMS layers. I
already have popups working on my whole map. When I click outside of object
e.g polygon the opened popup is empty. I would like to have popups which
apear only on objects (or more precisely, only on places where
GetFeatureInfo information is present).

This is GetFeatureInfo code which I use:

info = new OpenLayers.Control.WMSGetFeatureInfo({
        url: 'http://webgis.24gis.pl/geoserver/wms', 
        title: 'Identify features by clicking',
        queryVisible: true,
        infoFormat: 'text/html',
        maxFeatures: 1,
        eventListeners: {
            getfeatureinfo: function(event) {
                popup = new OpenLayers.Popup.FramedCloud(
                    "chicken", 
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true
                ), {
                    autoSize: false,
                    maxSize: new OpenLayers.Size(5,5)
                };
                map.addPopup(popup);
            }
        }
    });
    map.addControl(info);


Thank you in advance for any sugestion!

Michal

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Popup-only-on-WMS-layer-object-tp6648352p6648352.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110803/65e121d9/attachment.html


More information about the Users mailing list