[OpenLayers-Dev] asynchronous cross domain POST request inside openlayers

loic devaux devloic at gmail.com
Mon Apr 6 17:13:52 EDT 2009

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) {

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.lemoine at camptocamp.com
Dev mailing list
Dev at openlayers.org

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.

More information about the Dev mailing list