[OpenLayers-Users] GetFeatureInfo with loadURL

James Leveille James_Leveille at dmr.ca
Wed Apr 22 13:42:26 EDT 2009


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

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090422/780db1af/attachment.html


More information about the Users mailing list