1

I'm currently creating a webgis application using OpenLayers 3.0.0, and I'm trying to display a loading gizmo when loading layers from a WMS. I've found examples for OL 2.1.0 that registers 'loadstart' and 'loadend' events.

However I haven't had any success with registering those events in OL 3.0.

Anyone got any pointers on how to do this or know if this is even possible to do in OL 3.0?

Thanks!

3
  • I haven't had time to learn ol3 yet, but from what I have seen, you use the on function to listen to events, so something like: wms.on('change', function(){//do something}); See openlayers.org/en/master/apidoc/ol.source.ImageWMS.html. I have grepped the source code and there is no loadstart or loadend event, just change. Commented Sep 25, 2014 at 7:59
  • Thanks for the reply. I tried searching for the same event name in the code but didn't find anything either. It is rather odd to me that OpenLayers 2.1 had this functionality but OpenLayers 3.0 doesn't support it at all? Commented Oct 2, 2014 at 14:06
  • 1
    For the moment it is not possible. See: gis.stackexchange.com/a/121433/5375
    – acanimal
    Commented Nov 8, 2014 at 20:34

1 Answer 1

1

this works fine: Trigger event once layer is loaded

for example:

var wmssource =
new ol.source.ImageWMS({
    url: 'http://localhost:8080/geoserver/routing/wms',
    imageLoadFunction: function(image, src) {
        var imageElement = image.getImage();
        imageElement.onload = function() {
            console.log('loaded');
            $('#spinner').hide();
        };
        imageElement.src = src;
    }
});
var result = new ol.layer.Image({
source: wmssource
});
map.addLayer(result);
$('#spinner').show();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.