[OpenLayers-Users] GetFeatureInfo with loadURL

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Wed Apr 22 14:25:04 EDT 2009


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