jjimenezshaw / Leaflet.Control.Layers.Tree

a Tree Layers Control for Leaflet
https://jjimenezshaw.github.io/Leaflet.Control.Layers.Tree/examples/basic.html
BSD 3-Clause "New" or "Revised" License
146 stars 36 forks source link

Add WMS and WFS to Control Layers Tree #33

Closed Matt914 closed 3 years ago

Matt914 commented 3 years ago

Your tree control is amazing, you did a great job but can you please tell me how to add WMS and WFS? I'm following your examples but I'm a bit stuck in the overlays section because there are only place markers.

jjimenezshaw commented 3 years ago

Could you give me a full example of WMS in a normal Control Layers? I would like to understand how you use it.

Matt914 commented 3 years ago

I did this and I have to say that now it works. I can see the layer on my map. I gave the same order as you did in the airports example. I'm sorry but I'm new here and especially with this stuff. I just don't know how to write a good comment with codes in it

//layer added just before the basemaps like you did

var boundaries = L.tileLayer.wms('http://localhost:8080/xyz/city.territory/wms', { layers: 'city.territory:boundaries', format: 'image/png', transparent: true, });

var osm = L.tileLayer( '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '© OpenStreetMap contributors'} );

// Here I've built the overlays part var overlaysTree = { label: 'Geometries', selectAllCheckbox: 'Un/select all', children: [

   {  label: 'Territory',
        selectAllCheckbox: true,
        children: [
            {
                label: 'Elements',
                selectAllCheckbox: true,
                children: [
                    { label: 'Boarders', layer: boundaries }

                ]
            },
            /* ... */

        ]
    }
]

}

Here's how I've added my WMS from Geoserver.Please, excuse me again for the poor comment!

jjimenezshaw commented 3 years ago

I did this and I have to say that now it works... fixed, right? Then you can close the issue.