Skip to main content
Rollback to Revision 2
Source Link
TomazicM
  • 27k
  • 23
  • 31
  • 42

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);

I am also using an overlay where the layer is defined like this:

 active:true,
 name: "externe Maschinen",
 layer: extern

And I am also doing some visual customization of the overlay with the following code:

var panelElement = document.getElementById(extern._leaflet_id);
panelElement.parentNode.parentNode.style = 'border-color: #508B1B';

Do I just delete the old overlay and create a new one? Becuase thats what I tried. This sort of works as it unclusters the Markers but I am having trouble trying to remove the old Overlay, which stays on the screen.

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);

I am also using an overlay where the layer is defined like this:

 active:true,
 name: "externe Maschinen",
 layer: extern

And I am also doing some visual customization of the overlay with the following code:

var panelElement = document.getElementById(extern._leaflet_id);
panelElement.parentNode.parentNode.style = 'border-color: #508B1B';

Do I just delete the old overlay and create a new one? Becuase thats what I tried. This sort of works as it unclusters the Markers but I am having trouble trying to remove the old Overlay, which stays on the screen.

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);
added 586 characters in body
Source Link
CLa
  • 83
  • 1
  • 7

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);

I am also using an overlay where the layer is defined like this:

 active:true,
 name: "externe Maschinen",
 layer: extern

And I am also doing some visual customization of the overlay with the following code:

var panelElement = document.getElementById(extern._leaflet_id);
panelElement.parentNode.parentNode.style = 'border-color: #508B1B';

Do I just delete the old overlay and create a new one? Becuase thats what I tried. This sort of works as it unclusters the Markers but I am having trouble trying to remove the old Overlay, which stays on the screen.

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);

I am also using an overlay where the layer is defined like this:

 active:true,
 name: "externe Maschinen",
 layer: extern

And I am also doing some visual customization of the overlay with the following code:

var panelElement = document.getElementById(extern._leaflet_id);
panelElement.parentNode.parentNode.style = 'border-color: #508B1B';

Do I just delete the old overlay and create a new one? Becuase thats what I tried. This sort of works as it unclusters the Markers but I am having trouble trying to remove the old Overlay, which stays on the screen.

added 109 characters in body
Source Link
CLa
  • 83
  • 1
  • 7

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

I am using the Leaflet markercluster plug in, and now want to add a button to turn the clustering on/off. For that I wanted to use the leaflet button plug in, because I am already using it in my code.

I tried around with this piece of code and customized the lines with "sidebar" in it.

var button = new L.Control.Button('Toggle me', {
toggleButton: 'active'
});
button.addTo(map);
button.on('click', function () {
if (button.isToggled()) {
    sidebar.hide();
} else {
    sidebar.show();
}
});

I also have an overlay where I want to implement those layers then.

How I cluster my markers:

var extern2 = L.markerClusterGroup();
extern2.addLayer(extern);
Source Link
CLa
  • 83
  • 1
  • 7
Loading