[OpenLayers-Users] getFeatureInfo

Bill Woodall bwoodall at wardrobe.dhs.org
Fri Mar 30 04:27:13 EDT 2007


Great idea Brent!

So you gave me a idea!  User Recipes for OL and since OL is on wiki and
after a "it's a wiki, go crazy" from someone and learning the finer
points of WikiFormatting there is UserRecipes

http://trac.openlayers.org/wiki/UserRecipes


.......Bill,

On Thu, 2007-03-29 at 15:29 -0700, Brent Pedersen wrote:
> 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
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list