[OpenLayers-Users] Popups doubt in example "Feature Info in Popup"

Marcos Nogueira nomarcos at gmail.com
Wed Aug 26 14:53:26 EDT 2009


@Eric Lemoine

Eric, just go the examples page http://www.openlayers.org/dev/examples/
and type "feature info in popup". It's the first one that appears.

@Ziegler Stefan

Thanks for your suggestion.

I ended up solving it in a similar way.

Here's my previous code:

var info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: "http://127.0.0.1:8081/cgi-bin/mapserv.exe?map=c
:\\maps\\wms_postgis.map",
            title: 'Identify features by clicking',
            queryVisible: true,
            vendorParams: {
            "FEATURE_COUNT": "1000"},
            eventListeners: {
                getfeatureinfo:
                    function(event) {
                        map.addPopup(new OpenLayers.Popup.FramedCloud(
                            "chicken",
                            map.getLonLatFromPixel(event.xy),
                            null,
                            event.text,
                            null,
                            true
                        ));
                }
            }
        });
        map.addControl(info);
        info.activate();

and here's how I solved it:

var info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: "http://127.0.0.1:8081/cgi-bin/mapserv.exe?map=c
:\\maps\\wms_postgis.map",
            title: 'Identify features by clicking',
            queryVisible: true,
            vendorParams: {
            "FEATURE_COUNT": "1000"},
            eventListeners: {
                getfeatureinfo:
                    function(event) {
                     if((event.text).length != 1) {
                        map.addPopup(new OpenLayers.Popup.FramedCloud(
                            "chicken",
                            map.getLonLatFromPixel(event.xy),
                            null,
                            event.text,
                            null,
                            true
                        ));
                    }
                }
            }
        });
        map.addControl(info);
        info.activate();


Just an "if" solved.
Simpler than I expected :-P

thank you two!!

Marcos


On Wed, Aug 26, 2009 at 3:14 AM, Ziegler Stefan <Stefan.Ziegler at bd.so.ch>wrote:

> Hi Marcos
>
> my - not very sophisticated - approach:
>
>        function setHTML(response) {
>                if (response.responseText.indexOf('<body>  </body>') == -1)
> {
>                        // show popup....
>                }
>                else {
>                        // do not show popup...
>                }
>        }
> It simply checks wether the returned html stuff consists only of two body
> tags. Probably you have to change the check string according to your wms
> server's empty response.
>
> regards
> Stefan
>
>
>
>
>
> ----- Originalnachricht -----
> Von: Marcos Nogueira <nomarcos at gmail.com>
> Gesendet: Die, 25.8.2009 21:17
> An: users at openlayers.org
> Betreff: [OpenLayers-Users] Popups doubt in example "Feature Info in Popup"
>
> Hi,
>
> I managed to use GetFeatureInfo perfectly in my application after checking
> the example "Feature Info in Popup".
>
> Every point that I click that has some information to be returned gets it
> returned. It's great.
>
>
> But the problem is, when I click in a place in the map that has no
> information, I mean, a point from my WMS layer that has no
> information about it in my source, it returns an empty popup.
> That behaviour also happens in the example. If you click in the white area,
> for example, it returns you an empty popup.
>
>
> The question I have is:
> how do I make for the popup to appear only when there's some information
> being returned ??
>
> I'm using openlayers 2.8
>
> Thanks for the attention guys
>
> Marcos
>
>
>
>
>
> --
> "Saber o que é certo e não fazê-lo é a pior covardia."
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
"Saber o que é certo e não fazê-lo é a pior covardia."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090826/f729a7cf/attachment.html


More information about the Users mailing list