question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document layerGroup id option

See original GitHub issue

L.layerGroup has a function getLayer that finds layers by ids, but how layers get ids is unexplained

L.layerGroup({ foo: L.tileLayer('') }).getLayer('foo') // no dice

Is there an id option for layers? This needs better explaining around.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:6
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
mn113commented, Oct 28, 2016

Leaflet 1.0 came out but there is still no way to access layers other than with getLayerId(layer) and getLayer(id)

2reactions
skipjackcommented, Aug 4, 2020

Note that there is a fair amount of interest in something like this, you can see that in these two so questions that have garnered a decent number of votes:

Disclosure: I do have answers on both of those but in neither are the “leaflet recommended” approach. Would be happy to update my answers if there is one or for someone else to submit a new answer if there is a better/simpler built-in approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layer Groups and Layers Control - Leaflet - Leaflet
This tutorial will show you how to group several layers into one, and how to use the layers control to allow users to...
Read more >
How to get Name/ID of featureGroup when layer is clicked
No. Leaflet does not have a concept of "parent group". A L.Layer can belong to zero, one, or many L.LayerGroup s, e.g.:
Read more >
Does leaflet support user defined Layer identifiers
For example with a LayerGroup, the idea is to have a setId(<String> id) function that would allow leveraging the native removeLayer( ...
Read more >
ol/layer/Group~LayerGroup - OpenLayers
ol/layer/Group~LayerGroup. import LayerGroup from 'ol/layer/Group.js'; ... new LayerGroup(options) ... maxResolution, number, yes, change:maxresolution.
Read more >
Layer, group, and lock objects in Pages on Mac - Apple Support
You can work with and arrange the objects on a page in a number of ways: Layer (or stack) objects to create the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found