elesdoar / leaflet-control-orderlayers

Leaflet control with order functionality
http://elesdoar.me/leaflet-control-orderlayers/
MIT License
30 stars 10 forks source link

Can't add a layer group to the layer control #3

Open bwyss opened 9 years ago

bwyss commented 9 years ago

I am able to add the layer to the layer control, but not a layer group.

here is a snippet of what I am trying to do:


        var layerControl = L.control.orderlayers();

        var tileLayer = L.tileLayer(TILESTREAM_URL +
            selectedLayer +
            '/{z}/{x}/{y}.png',{wax: TILESTREAM_URL +
            selectedLayer +
            '.json'});

        var utfGridLoss = new L.UtfGrid(TILESTREAM_URL +
            selectedLayer +
            '/{z}/{x}/{y}.grid.json?callback={cb}', {Default: false, JsonP: false});

        var utfGrid = L.layerGroup([
            utfGridLoss,
            tileLayer
        ]);

        map.addLayer(utfGrid);
        layerControl.addOverlay(utfGrid, selectedLayer); // does not work
        layerControl.addOverlay(tileLayer, selectedLayer); // works
bwyss commented 9 years ago

I was able to get around this issue by using a leaflet featureGroup, but the UtfGrid layer does not follow the layer order change