heigeo/leaflet.wms

Drilldown identify

carrbrpoa opened this issue · 3 comments

Is there a solution/suggestion/plugin for drill down identify for displaying results?
I noticed that when there are some WMS layers activated and I click anywhere, one identify task for each layer is executed, but only the last processed is displayed.

Thanks in advance

If all of your layers are coming from the same wms.Source, there will be a single identify event. Otherwise, the plugin does not currently support identify with multiple sources (see #46). One workaround is to just disable the default identify on each source and replace it with a custom event, something like this:

var sources = {
    'source1': L.wms.source('...', {identify: false}),
    'source2': L.wms.source('...', {identify: false})
};

map.on('click', function(evt) {
    var responses = {},
        sourceNames = Object.keys(sources);

    sourceNames.forEach(function(name) {
        var source = sources[name];
        source.getFeatureInfo(
            evt.containerPoint,
            evt.latlng,
            source.getIdentifyLayers(),
            function(latlng, info) {
                responses[name] = info;
                updateMap();
            }
        );
    });

   function updateMap() {
        var html = sourceNames.map(function(name) {
            return "<h1>" + name + "</h1>" + (responses[name] || "Loading...");
        }).join("");
        map.openPopup(html, evt.latlng);
    }
});

That workaround does the trick. Thanks! 💯

How can I customize for each sources a table of attributes for wms that have info_format: application / json