[OpenLayers-Users] GetFeatureInfo with loadURL

James Leveille James_Leveille at dmr.ca
Wed Apr 22 14:50:43 EDT 2009


Hi Bart,

First, thanks for the answer.

Just to let you know that using "i" as my scope works fine with :

   OpenLayers.loadURL ( url, '', i, setHTML );

but not with :

   OpenLayers.loadURL ( url, '', i, function ( response ) { setHTML ( response ); });

where I get "[object Window]" instead of the actual value if "i" printed out (as I get with the first declaration).

Aren't those two declarations equivalent ?
Again, thanks for your help.

James




-----Message d'origine-----
De : Bart van den Eijnden (OSGIS) [mailto:bartvde at osgis.nl] 
Envoyé : 22 avril 2009 14:25
À : James Leveille
Cc : users at openlayers.org
Objet : Re: [OpenLayers-Users] GetFeatureInfo with loadURL

Hi,

one way is to use i as your scope:

OpenLayers.loadURL ( url, '', i, function ( response ) { setHTML ( 
response); });

function setHTML ( response)

{

alert ( this );

Best regards,
Bart

James Leveille wrote:
>
> Hi,
>
> I'm trying to send a getFeatureInfo to all queryable layers.
>
> In the "onComplete" function, I would like to be able to "know", for 
> each response, the index of the corresponding layer (the layer index 
> for which the request was sent).
>
> But the "index" value in the "onComplete" function is always wrong 
> (seems to be equal to "map.layers.length" value).
>
> How can I make sure the index is correctly passed ?
>
> Thanks a lot.
>
> function findLayerClick ( event )
>
> {
>
> var url;
>
> var mouseLoc = map.getLonLatFromPixel ( event.xy );
>
> for ( var i = 0; i < map.layers.length; i++ )
>
> {
>
> if ( map.layers[i].queryable )
>
> {
>
> url = map.layers[i].getFullRequestString
>
> ({
>
> REQUEST: "GetFeatureInfo",
>
> EXCEPTIONS: "application/vnd.ogc.se_xml",
>
> BBOX: map.getExtent().toBBOX(),
>
> X: event.xy.x,
>
> Y: event.xy.y,
>
> SRS: "EPSG:32187",
>
> INFO_FORMAT: "text/html; charset=ISO-8859-1",
>
> QUERY_LAYERS: map.layers[i].params.LAYERS,
>
> FEATURE_COUNT: 5,
>
> VERSION: "1.1.1",
>
> WIDTH: map.size.w,
>
> HEIGHT: map.size.h
>
> }, map.layers[i].url );
>
> OpenLayers.loadURL ( url, '', this, function ( response ) { setHTML ( 
> response, i ); });
>
> }
>
> }
>
> OpenLayers.Event.stop(event);
>
> }
>
> function setHTML ( response, index )
>
> {
>
> alert ( index );
>
> ... ... ... // manipulate the result
>
> }
>
> James
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Bart van den Eijnden
OSGIS, Open Source GIS
bartvde at osgis.nl
http://www.osgis.nl




More information about the Users mailing list