How to remove the whole container (see picture below) of leaflet-routing that includes distance and travel time via a button in my index.html?

unwanted container

If i remove line 3508 of leaflet-routing-machine.js: return this._container; the container is not visible. But this way is not an option.

  • That doesn't look like it's shown by default with leaflet-routing-machine (at least I've never seen it when I used the library). Are there any other Leaflet or routing-machine widgets in your map code, if so, can you show your map code?
    – chrki
    Apr 19, 2017 at 19:56
  • @chrki Its the via CSS modified leaflet-routing-container that normaly contains additional informations about your route. See here: liedman.net/leaflet-routing-machine
    – howard.D
    Apr 19, 2017 at 21:33

1 Answer 1


Adding show: false and collapsible: false to the control didn't seem to do the trick. But you can manipulate the container's CSS with Javascript this way:

control._container.style.display = "None";

To show it again later you can reverse this by doing:

control._container.style.display = "Block";
  • Thats not what iam looking for. Im looking for a way to remove this via a command in JS
    – howard.D
    Apr 21, 2017 at 23:57
  • @howard.D I edited my answer
    – chrki
    Apr 22, 2017 at 12:55
  • this actually did the trick. But im still struggling: i wanted to remove the container to change the ordner of my controls. A Button should be on top of topright ordner. Without removing the the rounting_container it overlays an input field. By using control._container.style.display = "None"; and control._container.style.display = "Block"; The container hides and then appears in the same position again and still hides my control.
    – howard.D
    Apr 23, 2017 at 12:41
  • 1
    solved: just used the CSS hacks for my button instead of for the routing container
    – howard.D
    Apr 23, 2017 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.