[OpenLayers-Users] getFeatureInfo
Brent Pedersen
bpederse at gmail.com
Thu Mar 29 18:29:29 EDT 2007
this might be useful. [ requires ows_include_items to be set in the mapfile ]
OpenLayers.Layer.WMS.prototype.getFeatureInfoURL = function(e /*,info_format*/){
var x = e.xy.x
var y = e.xy.y
var url = this.getURL(this.map.getExtent())
.replace(/getMap/i,'getFeatureInfo');
var ms = this.map.getCurrentSize();
var format = arguments.length > 1 ? arguments[1] : 'text/plain'
url += '&x=' + x + '&y=' + y
+ '&QUERY_LAYERS=' + this.params.LAYERS
+ '&INFO_FORMAT=' + format;
url = url.replace(/&width=[^&\?$]+/i,'&WIDTH=' + ms.w)
.replace(/&height=[^&\?$]+/i,'&HEIGHT=' + ms.h)
return url
};
example:
map.events.register('click',mapquery);
function mapquery(evt){
var url = muni.getFeatureInfoURL(evt);
OpenLayers.loadURL(url,{},this,function(req){
alert(req.responseText)
});
}
my test page here:
http://giifweb.cnr.berkeley.edu/fire/wind/gfi/gfi.html
More information about the Users
mailing list