Multilayer map breaks with JavaScript aggregation when using Maplibre libraries

Created on 23 December 2023, 12 months ago
Updated 17 January 2024, 11 months ago

Problem/Motivation

Thanks for including the Maplibre libraries from Leaflet 10.2.6, and Vector tiles support. It's nice to have everything ready to use after installing Leaflet module, without having to do anything else.

After Leaflet 10.2.6 where maplibre-gl-js & maplibre-gl-leaflet libraries js and css files was embedded in the Leaflet module itself, if you use the Maplibre libraries for example for Vector tiles, and you aggregate JavaScript files, you get a white page, and this message in the console:

Uncaught SyntaxError: redeclaration of const a
note: Previously declared at line 585, column 124988 
js_36Cc25ySfc_bCPZPMGkgRO6_2OjFQNpZD9P35kGaiS8.js:585:125091
js_36Cc25ySfc_bCPZPMGkgRO6_2OjFQNpZD9P35kGaiS8.js:585:124988

Steps to reproduce

  1. Add multiple layers as describe on https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib...
  2. Add a layer using the new Maplibre libraries (Leaflet 10.2.6) for example Vector tiles:
            'Stamen TonerLite Vector' => [
              'type' => 'vector',          
              'urlTemplate' => '//tiles.stadiamaps.com/styles/stamen_toner_lite.json',
              'options' => [
                "subdomains" => "abcd",
                "minZoom" => 0,
                "maxZoom" => 20,
                "ext" => "png",
                "attribution" => "&copy; <a href='https://www.stadiamaps.com/' target='_blank'>Stadia Maps</a> &copy; <a href='https://www.stamen.com/' target='_blank'>Stamen Design</a> &copy; <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> &copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors",
              ],
            ],
  3. Toggle JavaScript aggregation with this in settings.php (FALSE/TRUE):
    $config['system.performance']['js']['preprocess'] = FALSE;
  4. See that the map doesn't render with aggregation enabled

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

10.2

Component

Code

Created by

🇩🇰Denmark ressa Copenhagen

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

Comments & Activities

Production build 0.71.5 2024