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.

markers shared by multiple layers member of L.Control.Layers are disabled even if the remaining layers include them

See original GitHub issue

In leaflet 0.3.1, when the same marker is added to more than one layer, all of which are added to L.Control.Layers as overlays, and one of the overlays is disabled, the marker is disabled.

e.g.

var groupA = new L.LayerGroup(),
    groupB = new L.LayerGroup();

map.addLayer(groupA).addLayer(groupB);

var overlays = {
 "A features": groupA,
 "B features": groupB,
};

map.addControl(new L.Control.Layers(null, overlays));

var marker = new L.Marker(new L.LatLng(1.0, 1.0));
groupA.addLayer(marker);
groupB.addLayer(marker);

Now, whenever the “A features” overlay is disabled, the marker is removed, even if the “B features” overlay is still enabled. Disabling and re-enabling “B features” does re-add the marker.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rgeissertcommented, Apr 14, 2012

I wrote a workaround that does the trick for me. Perhaps this new behaviour should be hidden behind some forceReadd option or something, otherwise I might think its performance impact is not welcome.

1reaction
RinkAttendant6commented, Feb 10, 2020

@MaxiPigna I think the workaround is in the cross-referenced commit here: https://github.com/rgeissert/Leaflet/commit/e273f1bb0aeef485d07c2814429a28ea9ea07474

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 >
Filtering on multiple features with the use of L.control.layers so ...
To dynamically change GeoJSON layer filter with L.control.layers control, dummy nodisplayed layers can be used. These layers are used:.
Read more >
Leaflet for R - Show/Hide Layers - GitHub Pages
The Leaflet package includes functions to show and hide map layers. ... to individual markers and shapes, etc., while groups are used to...
Read more >
OpenLayers Examples
Example of ordering layers using Z-index. Layer Zoom Limits (layer-zoom-limits.html). Using minZoom and maxZoom to control layer visibility. Lazy Source
Read more >
NVIDIA Deep Learning TensorRT Documentation
TensorRT ships with a library of plug-ins, and source for many of these and ... DLA and the rest on GPU; for layers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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