Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to set default selection in LayerControl #1145

Open
dansiviter opened this issue Oct 28, 2024 · 0 comments
Open

[Question] How to set default selection in LayerControl #1145

dansiviter opened this issue Oct 28, 2024 · 0 comments

Comments

@dansiviter
Copy link

I'd like to know how to select the default layer within the LayerControl. Is seems this is a somewhat confusing thing outside of react so wonder if there is something I'm missing. I have the following:

const osm = (
    <TileLayer
      attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
      url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
      zIndex={ -1 }
  />);

  return (
    <MapContainer>
      { osm }
      <LayersControl position="topright">
        <LayersControl.BaseLayer name="OpenStreetMap">
        { osm }
        </LayersControl.BaseLayer>
        <LayersControl.BaseLayer name="OpenStreetMap HOT">
          <TileLayer
            attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a>'
            url="https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png"
          />
        </LayersControl.BaseLayer>
      </LayersControl>
 </MapContainer>
  )
}

But it doesn't select it:
image

I've tried a few variants moving the TileLayer around but to no avail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant