Tile rendering stops at zoom levels beyond 18

Created on 5 November 2021, about 3 years ago
Updated 2 November 2023, about 1 year ago

Problem/Motivation

I have a leaflet map displaying in a view and have set the max zoom to 20. When viewing the map, any zoom level beyond 18 doesn't render the tiles.

See attached screenshots for the map showing at a zoom level of 18, then 19+.

Here's what I've tried...
- Changing "maxZoom" manually everywhere within the leaflet module. Clearing cache. Didn't fix.
- I am using Leaflet Mapbox, and have tried changing the max zoom setting in the module's code and config. Still no go.
- Vast searching the code of my entire site for maxZoom, changing all to 20. Nope.

Any tips on getting these higher than 18 zooms displaying tiles correctly? Thanks!

💬 Support request
Status

Fixed

Version

2.1

Component

Miscellaneous

Created by

🇺🇸United States chucksimply

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany e5sego

    I got the same issue in the 10.1.0 version of this module and found a solution.

    The library js/leaflet/dist/leaflet.js has a hardcoded value for maxZoom set to 18, which has to be changed to 22.

    Attached you will find a fixed and zipped version of this file.
    (a patch does not make sense for compressed javascript)

  • 🇮🇳India newswatch Delhi/Bangalore

    Solution #6 is perfect. I set it to the max level of 22, and the result is just as desired :)

  • 🇺🇸United States chucksimply

    Worked for me as well! Thanks! Is there no way to make this more of a permanent fix?

  • 🇺🇸United States chucksimply

    Why would a patch not make sense? Every time the module is updated, the MaxZoom reverts back to 18.

  • 🇩🇪Germany e5sego

    I meant it technical-wise. The compressed leaflet.js has only one line of real code, so the patch contains the whole file.

    But for those who want to automate the process of patching using composer, I attached a patch file.

    The regarding section for composer.json would look like:

            "patches": {
                "drupal/leaflet": {
                    "Fix leaflet maxZoom factor. See https://www.drupal.org/project/leaflet/issues/3247962": "https://www.drupal.org/files/issues/2023-11-01/3247962-Leaflet-fix-maxZoom.patch"
                }
            }
    
  • Status changed to Fixed about 1 year ago
  • 🇮🇹Italy itamair

    To increase the Max zoom to the selected Tiles the proper "maxZoom" property is required to be set in the "options" definition of the specific Leaflet Map Tile (whose max zoom I want to enhance), as suggested from the following Stackoverflow page: https://stackoverflow.com/questions/38126343/leaflet-how-to-increase-max...

    In particular see the example implementation of the hook_leaflet_map_info() in the leaflet.api.php

    So for instance I should could set the following definition of the OSM Mapnik:

    /**
     * Implements hook_leaflet_map_info().
     */
    function mymodule_leaflet_map_info() {
      return [
        'Custom OSM Mapnik' =>
          [
            'label' => 'Custom OSM Mapnik',
            'description' => t('Leaflet OSM Mapnik map with 22 Max Zoom.'),
            'settings' => [
              'dragging' => TRUE,
              'touchZoom' => TRUE,
              'scrollWheelZoom' => TRUE,
              'doubleClickZoom' => TRUE,
              'zoomControl' => TRUE,
              'zoomControlPosition' => 'topleft',
              'attributionControl' => TRUE,
              'trackResize' => TRUE,
              'fadeAnimation' => TRUE,
              'zoomAnimation' => TRUE,
              'closePopupOnClick' => TRUE,
            ],
            'layers' => [
              'earth' => [
                'urlTemplate' => '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                'options' => [
                  <strong>'maxZoom' => 22,</strong>
                  'attribution' => '&copy; <a href="https://www.openstreetmap.org/copyright" rel="noopener noreferrer" target="_blank">OpenStreetMap</a> contributors',
                ],
              ],
            ],
          ],
      ];
    }

    and I will be able to successfully Zoom-in further then 18 if:

    1. I also properly set the Leaflet Map "Max. Zoom" option higher than 18 ...
    2. The specific Map Tile (in this case the OSM Mapnik ...) properly supports and provides Map Tiles at Zoom level higher than 18 ...

    You could also simply tryout the attached patch that alters the Leaflet module OSM Mapnik default definition to have a Max Zoom of 22 ...

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024