MapboX GL JS Composer Libs + JQuery once, Marker icons, Show Controls & Fullscreen Control Adjustments

Created on 9 March 2025, 5 months ago

Problem/Motivation

Hello, I had to integrate mapbox block to the site, and faced few errors. Just posting the patch if you want to fix some of the points in the module directly or for people who will check errors state as I did but couldn't find any fixes here and help them find a quick solution in form of the patch.

In order to install mapbox gl js libs adjust composer:

1. Add the proper repository to you composer.json file to be able to require
the JS library. We need npm-assets, merge following
in project root's composer.json file.

    json
      "repositories": {
        "npm-assets": {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
      }

2. We also need to ensure npm-asset is added as Drupal Library. Merge following
in project root's composer.json file.

      "extra": {
        "installer-types": [
            "npm-asset"
        ],
        "installer-paths": {
          "web/libraries/{$name}": [
            "type:npm-asset"
          ],
        }
      }

It is always good to download and use the latest version here but new
versions may not work as expected since those are not tested properly.

3. Require following composer dependencies.

composer require oomphinc/composer-installers-extender
composer require npm-asset/mapbox-g:3.8

Patch changes

* Use composer nom asset default library location for js and css includes
* Use Drupal once as jQuery one caused issue on core 10.4.3
* By default marker-15 icon now isn't found and rendered as a fallback dot, use js markers approach to add html markers on top of gl canvas and allow direct styling if needed
* Fix missing show controls Drupal settings which leaded to missing controls even if setting was available
* Add Fullscreen control as well

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇬🇷Greece Pavel Ruban

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

Comments & Activities

Production build 0.71.5 2024