Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Usage Milestone: Time Field for Drupal 8+ Module time_field crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Maplibre GL

No security coverage
View on drupal.org

This module provides integration with MapLibre GL JS, an open-source fork of Mapbox GL JS. It allows developers to create interactive maps using API calls, specifying map styles, data sources, and visual controls. Maps can display geographic data, including GeoJSON and vector tiles, and can be configured to show layer properties in popups or separate content areas.

Due to the changes of mapbox terms of use. This is a fork of module https://www.drupal.org/project/mapbox_gl/ to use maplibre instead of mapbox , more to read in https://www.maptiler.com/news/2021/01/maplibre-mapbox-gl-open-source-fork/ and https://maplibre.org/maplibre-gl-js/docs/

Initial code for integration with Maplibre GL JS.

This is an API only module. There is no UI. Maps can be generated using hook_maplibre_gl_info() and calling the render method.

popup should either be "popup" to display the layer properties in a popup, or the ID of a separate element in which to display the information. e.g. "my-properties-div".

"My Locations" in the example below is a tile set created within Mapbox Studio (or uploaded). The URL includes the "Map ID" found on the Tileset's page.

e.g.

function hook_maplibre_gl_map_info() {
  // For options, see: https://maplibre.org/maplibre-gl-js/docs/API/
  return [
    'Streets' =>
    [
      'access_token' => '<Your access token>',
      'options' => [
        'container' => 'mapv2',
        'style' => 'https://api.maptiler.com/maps/basic-v2/style.json',
        'zoom' => 6,
        'center' => [146.315918, -41.640079],
      ],
      'config' =>
      [
        'height' => '400px',
        'popup' => 'popup',
        'controls' =>
        [
          'NavigationControl' => 'top-left',
          'AttributionControl' => [
            'compact' => true
          ],
          'MaplibreGeocoder' => [
            'accessToken' => '<Your access token>'
          ]
        ]
      ],
      'layers' =>
      [
        [
          'id' => 'Ports',
          'type' => 'circle',
          'source' => [
            'type' => 'geojson',
            'data' => 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'
          ]
        ],
        [
          'id' => 'Terrain',
          'type' => 'line',
          'source' =>
          [
            'type' => 'vector',
            'url' => 'https://api.maptiler.com/maps/streets/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL',
          ],
          'source-layer' => 'contour',
          'layout' => [
            'line-join' => 'round',
            'line-cap' => 'round',
          ],
          'paint' => [
            'line-color' => '#ff69b4',
            'line-width' => 1
          ],
          [
          'id' => 'My Locations',
          'type' => 'circle',
          'source' => [
            'type' => 'vector',
            'url' => 'maplibre://companyname.cj9s1qkic03un32plq1klqfms-5c4qn'
          ],
          'source-layer' => 'My_Locations_Tileset'
        ]
      ]
    ]
  ];
}

To display the map:

use Drupal\maplibre_gl\Controller\MaplibreGlController;

$map = MaplibreGlController::renderMap('Streets');

Drupal Content as Source Data

To use Drupal content as source data for a layer, create a path with Maplibre compatible output. For example, create a View with GeoJSON output.

e.g. https://www.mysite.com/my-locations.geojson

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Mar 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
3.0.x-dev Dev 9–11 Mar 4, 2025