Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateTimeDimension only works when layer is queryable #139

Open
pineapplegum opened this issue Feb 4, 2018 · 1 comment
Open

updateTimeDimension only works when layer is queryable #139

pineapplegum opened this issue Feb 4, 2018 · 1 comment

Comments

@pineapplegum
Copy link

Hi, thanks for a great library! By looking at the source code, it seems like the updateTimeDimension = true will only work if the layer is set as queryable=1 in the getcapabilities. If it is set to 0, no times are returned. Is it somehow possible to bypass this and use updatetimedimension on non-queryable layers?

@beihl
Copy link

beihl commented Apr 16, 2018

A hack/workaround would be to replace the parsing function.

This is a copy of the original without the 'queryable' requirement :

let parseTimeDimensionFromCapabilitiesFix =  function(xml) {

      //// old selector
      //// var layers = xml.querySelectorAll('Layer[queryable="1"]');

      //// new selector
        var layers = xml.querySelectorAll('Layer]');


        var layerName = this._baseLayer.wmsParams.layers;
        var layer = null, times = null;
        layers.forEach(function(current) {
            if (current.querySelector("Name").innerHTML === layerName) 
                layer = current;
        })
        if (layer) {
            times = this._getTimesFromLayerCapabilities(layer);
            if (!times)
                times = this._getTimesFromLayerCapabilities(layer.parentNode);
        }
        return times;
}

Then replace the parser after creation :

let wmsTimeLayer = L.timeDimension.layer.wms( ... )
wmsTimeLayer._parseTimeDimensionFromCapabilities = parseTimeDimensionFromCapabilitiesFix;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants