[OpenLayers-Users] WMSGetFeatureInfo not firing

P Kishor punk.kish at gmail.com
Sat Sep 19 21:20:10 EDT 2009


On Sat, Sep 19, 2009 at 7:47 PM, P Kishor <punk.kish at gmail.com> wrote:
> I have a bizarre problem that I can't debug. My code is
>
> var info = new OpenLayers.Control.WMSGetFeatureInfo({
>            url: "http://localhost/cgi-bin/mapserv?map=/path/to/my.map&",
>            maxFeatures: 12,
>            title: 'Identify features by clicking',
>            queryVisible: true,
>            layers: [wms_cds_stands],
>            infoFormat: "text/plain",
>            eventListeners: {
>                getfeatureinfo: function(event) {
>                    map.addPopup(new OpenLayers.Popup.FramedCloud( ... ), true);
>                }
>            }
>        });
>        map.addControl(info);
>        info.activate();
>
> If I change the url to "http://localhost/cgi-bin/mapserv" it fires
> correctly on click, and a framed cloud pops up with the error message
> that CGI variable map is not declared. However, if I add the map
> variable to the query string as shown above, then the event doesn't
> fire on click at all. There is no proxy nor remote host involved.
> Everything is on localhost. Doesn't matter if the url starts with
> "http://localhost/cgi-bin//mapserv" or just "/cgi-bin//mapserv", it is
> the presence of the url query string that seems to cause the click
> event to not fire at all.
>
> What could I do to correct this?
>

So, after two days of struggling with this, I figured it out. Turns
out, my layer was defined like so...

var wms_cds_stands = new OpenLayers.Layer.WMS(
  "CDS Stands",
  "http://localhost/cgi-bin/mapserv",
  { map: "/path/to/my.map", layers : "cds_stands", map_imagetype:
"agga", transparent: true },
  { reproject: true, singleTile: true }
);

and my WMSGetFeatureInfo control had url set like so

url: "http://localhost/cgi-bin/mapserv?map=/Users/punkish/Data/cnnf/cnnf.map&"

Well, the urlMatches() function in WMSGetFeatureInfo class was causing
my control to fail. The url for my layer definition did not have the
map parameter attached as a query string. Instead, it was provided as
a separate parameter in the params hash supplied to the object
constructor. However, the control constructor does not provide a
similar facility to supply the map value separately.

I changed my mapserver url in the layer constructor to

"http://localhost/cgi-bin/mapserv?map=/Users/punkish/Data/cnnf/cnnf.map&"

and now since urlMatches() returns true for the two urls, the click
event fires and I get a popup bubble.

Once again, I ask, was there a more efficient and obvious way for me
to discover this?

OpenLayers is an absolutely fantastic piece of work which is severely
hampered by its documentation, UNLESS, there is a strategy to
discovering how it works that I am completely missing. I am determined
to using OL and making it a showcase in my work, so I can also
evangelize it to others as a replacement for Google or Yahoo maps.
But, right now, either its documentation, or the way I am going about
it, is tripping me up severely. Any advice from you more seasoned
folks is very welcome.




-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
Sent from Madison, WI, United States



More information about the Users mailing list