Thanks for your help everyone...you're right Chris, I'm using GeoServer not Mapserver. So on Ivan's suggestion (and with Aleda's help) I went with a WFS GetFeature request with a +/- 5 pixel BBOX (to make the points and lines easier to select) and a custom list of fields (not including the geometry), and parsed the GML2 response into what I needed. Actually easier-to-code and more functional than before!
Here's the URL and some code snippets...there are actually separate loadURL requests for the line and point layer queries now; this is just the code for querying the line layer... http://maps.massgis.state.ma.us/dcr/trails/DCR_RoadTrail12.html // ======== THE EVENT CODE (PART OF THE INIT FUNCTION): map.events.register('click', map, function (e) { exy = e.xy; llMin = map.getLonLatFromPixel(new OpenLayers.Pixel(e.xy.x - 5,e.xy.y + 5)); // don't know why these have to be backwards on the Y coordinates... llMax = map.getLonLatFromPixel(new OpenLayers.Pixel(e.xy.x + 5,e.xy.y - 5)); // don't know why these have to be backwards on the Y coordinates... var url2 = map.layers[0].getFullRequestString( { SERVICE: 'WFS', VERSION: '1.0.0', REQUEST: "GetFeature", TYPENAME: 'massgis:DCR.ROADS_TRAILS_LINE', OUTPUTFORMAT: 'GML2', PROPERTYNAME: lineFieldListString, MAXFEATURES: 20, SRSNAME: 'EPSG:26986', BBOX: llMin.lon + "," + llMin.lat + "," + llMax.lon + "," + llMax.lat }, "http://giswebservices.massgis.state.ma.us/geoserver/wfs"); OpenLayers.loadURL(url2, '', this, setHTMLLine, setHTMLLine); OpenLayers.Event.stop(e); }); // ======== AND THE FUNCTION THAT IS CALLED WHEN THE GML IS RETURNED (most of this is specific to placing the values on the web page): function setHTMLLine(response) { var myGMLFormat = new OpenLayers.Format.GML(); var myGML = myGMLFormat.read(response.responseText); // ---- IF A LINE WAS CLICKED, FILL THE LINE BOX if ((myGML.length > 0) && (map.getScale() <= maxLineScale)) { for (var k in myGML[0].attributes) { // only uses the attributes of the first Line returned for now... // ----- This places the value into a new variable and truncates it if it's a long URL; this variable is used only for placing the text on the screen, not for href values. This way you can have a link with its actual href string separate from its truncated presentation on-screen var thisIsTheValue = myGML[0].attributes[k]; // ----- PLACE THE VALUES INTO THE CORRECT AREAS IN THE ATTRIBUTE DISPLAY AREA (if a place for them exists) // ----- This places the value onto the page if ((document.getElementById("LINE_" + k)) && (document.getElementById("LINEROW_" + k))) { // if a row for this attribute exists in the line table-box document.getElementById("LINE_" + k).innerHTML = thisIsTheValue; // write the attribute value into the table-box document.getElementById("LINEROW_" + k).style.display = ''; // make this table-box row visible } // end if } // end for (k) document.getElementById("lineTableHeader").innerHTML = "Road & Trail Line Attributes"; } // end of GPS LINE section else { document.getElementById("lineTableHeader").innerHTML = "No Road/Trail clicked"; } } // end of function setHTMLLine --David ||||||| David Kimball ||||||| GIS Specialist ||||||| MA Department of Conservation and Recreation ||||||| http://www.mass.gov/dcr/stewardship/gis/ ||||||| [email protected] ||||||| 617.626.1447 phone ||||||| 617.626.1349 fax -----Original Message----- From: Ivan Grcic [mailto:[email protected]] Sent: Friday, January 30, 2009 5:09 AM To: Christopher Schmidt Cc: Richard Greenwood; [email protected]; Kimball, David (DCR) Subject: Re: [OpenLayers-Users] WMS GetFeatureInfo - difficult to click exactly on a point Hi, i think its 2px default in Geoserver and cant be configured still. You have to write ur own WFS request where u calculate BBOX.. Take a look at wfsgetfeature control, might help http://dev.openlayers.org/sandbox/topp/wfs/examples/wfs-getfeature.html cheers On Fri, Jan 30, 2009 at 5:36 AM, Christopher Schmidt <[email protected]> wrote: > On Thu, Jan 29, 2009 at 07:20:38PM -0700, Richard Greenwood wrote: >> > Kimball, David (DCR) wrote: >> >> Hi everyone, >> >> >> >> I'm using a WMS GetFeatureInfo to simultaneously query the attributes of >> >> a line layer and a point layer (from GeoServer). Unfortunately you have >> >> to click *exactly* on the center of a point to get it to send you the >> >> point attributes. > >> Look at TOLERANCE in http://www.mapserver.org/mapfile/layer.html > > The original poster said he was using GeoServer. Although MapServer > does have a TOLERANCE parameter, I do not believe that there is a > corresponding functionality in GeoServer. > > Regards, > -- > Christopher Schmidt > MetaCarta > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > -- Ivan Grcic > Kimball, David (DCR) wrote: >> Hi everyone, >> >> I'm using a WMS GetFeatureInfo to simultaneously query the attributes of >> a line layer and a point layer (from GeoServer). Unfortunately you have >> to click *exactly* on the center of a point to get it to send you the >> point attributes. >> >> http://maps.massgis.state.ma.us/dcr/trails/DCR_RoadTrail10.html >> >> >> map.events.register('click', map, function (e) { >> var url = map.layers[0].getFullRequestString( >> { >> REQUEST: "GetFeatureInfo", >> EXCEPTIONS: "application/vnd.ogc.se_xml", >> BBOX: map.getExtent().toBBOX(), >> X: e.xy.x, >> Y: e.xy.y, >> INFO_FORMAT: 'text/html', >> QUERY_LAYERS: map.layers[8].params.LAYERS + "," >> + map.layers[9].params.LAYERS, >> FEATURE_COUNT: 50, >> WIDTH: map.size.w, >> HEIGHT: map.size.h >> }, >> >> "http://giswebservices.massgis.state.ma.us/geoserver/wms"); >> OpenLayers.loadURL(url, '', this, setHTML, setHTML); >> OpenLayers.Event.stop(e); >> >> >> I searched a bunch for this and all I could find were suggestions to do >> a WFS getfeature instead of a WMS GetFeatureInfo, or to set some options >> on the server (not an option in this case). I'd rather use the WMS >> request because I'd rather not rewrite all my parsing Javascript, and >> there might be a performance hit - some of the lines have hundreds of >> vertices, and when I tried a similar approach recently with large >> polygons it was slow because of the large amount of data sent back. >> >> So, is there any (client-side) radius/tolerance option for >> GetFeatureInfo? >> >> Thanks a lot, >> >> David Look at TOLERANCE in http://www.mapserver.org/mapfile/layer.html -- Richard Greenwood [email protected] www.greenwoodmap.com _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
