Leaflet will become even better if you add …

Make layer control docs/example clearer about which layer is shown initially

When there is multiple base layers, one is only visible, but all are always loaded. Please optimise this this.

10 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Frederic Rodrigo shared this idea  ·   ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Husmukh Maheshwari commented  · 

        any one got fix of this issue. I am also looking for a mechanism to set a default base layer when multiple layers added in control.

      • Per Lindberg commented  · 

        By the way, I would call this a bug, not just a shortcoming in the documentation. The API is incomplete and counterintuitive. If multiple base layers are allowed at the creation of the map, then either a RULE or a MECHANISM is needed to specifiy which one is default. Preferably both. The current behaviour is bad; there's no point in showing ALL the base layers in split-second sequence (overpainting each other).

      • Jeff Hoffmann commented  · 

        I think the documentation is not clear with regards to the layers control and that is causing confusion. I think it seems like you may need to add a layer to a map before it is made available in the layer control, which is not the case. If you create the layer objects and only add the base layer to the map that you want to show by default, it will only draw that one layer. You can still include all of the rest of your layers in the layer control list even if they haven't been added to the map and they will only load when you toggle them on in the layer control. If you add all of the layers to the map when you create the map, they will all draw on top of each other, which I think is the problem he is having.

      Feedback and Knowledge Base