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

Leaflet maxNativeZoom does prevent tiles from un-rendering when maxZoom > maxNativeZoom #1143

Open
michaelnicol opened this issue Sep 6, 2024 · 2 comments

Comments

@michaelnicol
Copy link

Bug report in v4

I am trying to allow a 25x max zoom, but stop the rendering of map tiles at a rendering of 18.

To do this, I use the following code:

import "./styles.css";
import { MapContainer } from "react-leaflet/MapContainer";
import { TileLayer } from "react-leaflet/TileLayer";
import "leaflet/dist/leaflet.css";

export default function App() {
  return (
    <>
      <MapContainer
        center={[51.505, -0.09]}
        zoom={13}
        style={{
          position: "fixed",
          top: 0,
          left: 0,
          height: "100%",
          width: "100%",
          zIndex: 1,
        }}
        maxZoom={25}
      >
        <TileLayer
          url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
          attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
          maxNativeZoom={18}
        />
      </MapContainer>
    </>
  );
}

You can also find it here: https://codesandbox.io/p/sandbox/leaflettest-f97lpf?file=%2Fsrc%2FApp.js%3A1%2C1-31%2C1

The issue is that when I zoom in past a zoom level of 18, the maxNativeZoom doesn't kick in. It tries to render more tiles and results in a gray region:

image

The expected behavior is for the tiles to stay rendered, even if the image gets blurry.

@karlvonbonin
Copy link

Any fixes here?

@michaelnicol
Copy link
Author

michaelnicol commented Dec 11, 2024

None. It's still broken regardless of the map layer I try. It's not optimal considering we have a specific use case in our application where this zoom is required.

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

2 participants