[OpenLayers-Users] Way to detect if layer is done loading?

Paul Spencer pagameba at gmail.com
Wed Oct 17 08:53:54 EDT 2007


Placing something in the middle is tricky :)  In general, you can put  
another element inside the element your map is in ... something like:

<div id="map">
   <img id="loadingImage" ...>
</div>

and in css:

#loadingImage {
   position: absolute;
   top: 50%;
   left: 50%;
}

this isn't exactly in the center though.

Cheers

Paul

On 16-Oct-07, at 9:12 PM, bradleyspencer wrote:

> Paul,
>
> Thanks for your advice it worked a treat.
>
> Just one more small question. I want to place this image in the  
> middle of
> the map which could change if I adopted a fullscreen approach. I  
> can get the
> lon/lat of the map centre and I can convert that to pixels but it  
> does not
> seem to be in the middle. Do you know how to do that in OL?
>
> Cheers,
>
> Brad Spencer
> http://www.cubewerx.com.au
>
> -----Original Message-----
> From: Paul Spencer [mailto:pagameba at gmail.com]
> Sent: Wednesday, 17 October 2007 10:12 AM
> To: brad at cubewerx.com.au
> Cc: Christopher Schmidt; Edward Fialkowski; users at openlayers.org
> Subject: Re: [OpenLayers-Users] Way to detect if layer is done  
> loading?
>
> Brad,
>
> you should be able to do something like this:
>
> /* for each layer in onload: */
> layer.events.register('loadstart', loadStart);
> layer.events.register('loadend', loadEnd);
>
>
> /* global functions/vars */
> var layersLoading = 0;
> function loadStart() {
>    if (layersLoading == 0) {
>      showLoadingImage();
>    }
>    layersLoading++;
> }
>
> function loadEnd() {
>    layersLoading--;
>    if (layersLoading == 0) {
>      hideLoadingImage();
>    }
> }
>
> this is rudimentary, untested ...
>
> Cheers
>
> Paul
>
> On 16-Oct-07, at 7:27 PM, bradleyspencer wrote:
>
>> I am trying to implement a Loading Image as well. I have managed to
>> use
>> LayerLoadMonitoring example to build my own Loading thingy.
>>
>> See http://demo.cubewerx.com.au/layerload.html
>>
>> This works fine for single layers as activate the Loading Image as
>> start of
>> load and I kill it off once that layer has loaded.
>>
>> However, if there are multiple layers active and there is a time
>> difference
>> between loading layers, the loading image has gone after the first
>> layer has
>> completed loading.
>>
>> I'm not sure how I can modify this to kill off the Loading Image
>> only after
>> all layers are loaded.
>>
>> Can anyone help me here?
>>
>> Cheers,
>>
>>
>> Brad Spencer
>> http://www.cubewerx.com.au
>>
>> -----Original Message-----
>> From: users-bounces at openlayers.org [mailto:users-
>> bounces at openlayers.org]On
>> Behalf Of Christopher Schmidt
>> Sent: Tuesday, 16 October 2007 7:15 AM
>> To: Edward Fialkowski
>> Cc: users at openlayers.org
>> Subject: Re: [OpenLayers-Users] Way to detect if layer is done
>> loading?
>>
>> On Mon, Oct 15, 2007 at 03:16:14PM -0500, Edward Fialkowski wrote:
>>> Hi List, I would really like to add a loading image to my app to
>>> show when
>> a
>>> layer is still being downloaded, but I'm having difficulty getting
>>> the
>> right
>>> javascript code.
>>>
>>> One option is if it's possible to know in openlayers when a WMS
>>> image is
>>> finished downloading and added to the map.
>>>
>>> Has anyone ever tried anything like this?
>>
>> http://openlayers.org/dev/examples/layerLoadMonitoring.html
>>
>> Regards,
>> --
>> Christopher Schmidt
>> MetaCarta
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>
> +-----------------------------------------------------------------+
> |Paul Spencer                          pspencer at dmsolutions.ca    |
> +-----------------------------------------------------------------+
> |Chief Technology Officer                                         |
> |DM Solutions Group Inc                http://www.dmsolutions.ca/ |
> +-----------------------------------------------------------------+
>
>

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+








More information about the Users mailing list