The openLayers controls  ( and this includes the Layerswitcher) shouldn't need 
to know when the data has been received but technically speaking it is the only 
place I found where I could insert the code fetching the data and still keep a 
synchronous behaviour.
Why do I need synchronous execution and what data am I fetching?
The new openLayers layer type I implemented to interact with CartoWeb server 
part uses code found in the WMS layer type so there is a getURL() function  
that is in charge of returning the url of the generated bitmap representation 
of the layer. So when getUrl() gets executed data must have already been 
retrieved. In my case data is a soap response containing the url of the 
generated bitmap and coordinates of each geometry so I can create placemarks. 
If I don't have synchronous execution then I have no guarantee that getUrl() 
will be able to return the url since it might not be able to extract the url 
from the soap response if the response didn't arrive yet ( which might be the 
case when things are done asynchronously). 

Because the code in the LayerSwitcher launched when the user clicks on a layer 
checkbox  is simple : 

onInputClick: function(e) {
....
                this.layerSwitcher.updateMap();         
.....

I can pass the updateMap() function as a callback to the onLoad event of the 
iframe so once the iframe retrieves the data it calls updateMap() which later 
on calls getUrl() which is happy to process the data.

Unfortunately this is not easy to implement for other controls...





Hi Loïc

Just a quick comment. I fail to see why you need synchronous behavior
here, e.g. why would the LayerSwitcher need to know when the data has
been received?

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev



-- 
View this message in context: 
http://n2.nabble.com/asynchronous-cross-domain-POST-request-inside-openlayers-tp2563656p2595465.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.

_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev

Reply via email to