Giter Site home page Giter Site logo

l.layertreecontrol's Introduction

L.LayerTreeControl

A leaflet plugin to group multiple types of layers in a tree structure.

Screenshot

Demo

Usage Example

var esriSampleUsa = L.esri.dynamicMapLayer({
  url: 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer',
  opacity: 0.7,
  layers: [],
});

var wmsGlobalPopulation = L.tileLayer.wms('https://sedac.ciesin.columbia.edu/geoserver/wms?', {
  layers: 'gpw-v3:gpw-v3-population-density_2000',
  transparent: true,
  format: 'image/png',
});

// define tree structure
var layers = [
  {
    layer: esriSampleUsa,
    name: 'Sample USA (esri)',
    type: 'esriDynamic',
  },		
  {
    type: 'leaflet',
    name: 'Custom tree',
    children: [
      {
        name: 'Level 1',
        children: [
          {
            name: 'Global Population',
            layer: wmsGlobalPopulation,
          },
        ],
      },
    ],
  },
];

var layerTreeCtrl = new L.Control.LayerTreeControl(layers, {
  position: 'topright',
});

map.addControl(layerTreeCtrl);

l.layertreecontrol's People

Contributors

dandormont avatar ignaciofagian avatar

Stargazers

 avatar Degenoah avatar Thantham K. avatar  avatar  avatar Gabriel Doyle Balk avatar Nurul Haya avatar Rebecca Walbecq avatar  avatar Suresh avatar

Watchers

 avatar

l.layertreecontrol's Issues

Preview order of layers

Hi, nice work..

It would be nice to be able to change the display order of dynamically loaded and marked layers. Optionally, changing the order will be an option.

Thnx.

Layers in sub-tree do not appear.

I am trying to add layers as children (geoJSON layers), but they do not appear when the boxes are checked. (They do appear if part of the top layer). That is, this works:

{
  type: 'leaflet',
  name: 'Boundaries',
  layer: placeGeom,
},
{
  type: 'leaflet',
  name: 'Field',
  layer: L.geoJSON( ... ),
}

but this does not:

{
  type: 'leaflet',
  name: 'Boundaries',
  layer: placeGeom,
},
{
  type: 'leaflet',
  name: 'Fields',
  children: [
    {
      type: 'leaflet',
      name: 'Field',
      layer: L.geoJSON( ... ),
    },
  ],
},

Am I missing something obvious?

Get all layers in tree from Geoserver Group Layers

This is by far the best leaflet Layer tree control I have found online. Kudos to you!
I have been playing with it and I am quiet happy with it. Not actually any issue but would be good to have following options-

  1. A Method to list all layers from Geoserver's Layer Group(WMS) in the tree. I noticed that when the Layer Group mode is 'single', it gets all the children's style and draws legend.. that is cool! For 'leaflet' type it is getting all 'layerObj.legend'. It would be nice to have 'layerObj.Layer' in 'leaflet' type just like what you have for 'esriDynamic' type. OR a completely new type for geoserver.

  2. Option - default 'expand all parents'/'collapse all parents'.

  3. Option - default 'check/uncheck all parent nodes'

I would appreciate any suggestions to achieve above mentioned points using your extension.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.