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

Drilldown identify #45

Closed
carrbrpoa opened this issue Jun 2, 2017 · 3 comments
Closed

Drilldown identify #45

carrbrpoa opened this issue Jun 2, 2017 · 3 comments

Comments

@carrbrpoa
Copy link

carrbrpoa commented Jun 2, 2017

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

@sheppard
Copy link
Member

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);
    }
});

@carrbrpoa
Copy link
Author

That workaround does the trick. Thanks! 💯

@fedemap
Copy link

fedemap commented Jan 20, 2020

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

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

3 participants