[OpenLayers-Users] getFeatureInfo
Brent Pedersen
bpederse at gmail.com
Fri Mar 30 14:19:15 EDT 2007
cool!
that's a much better way of forming the url. though we should use a
proxy so will only work for non-local wms requests.
if it's a prototype method or a bound function, then it can be more
generic, using this.getFullRequestString() instead of the hard coded
prox.
On 3/30/07, Bill Woodall <bwoodall at wardrobe.dhs.org> wrote:
> 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