Add multiple Leaflet layers with Leaflet Layers module

Last updated on
3 October 2024

You can add and manage multiple map layers with the Leaflet Layers module.

Leaflet Layers Map
This image is generated by ressa, using Leaflet Layers module.

The Leaflet layers module gives you ability to  combine layers from multiple modules & resources into bundles, using Drupal UI.

First, you need to download Leaflet Layers module with composer, in your project root:

composer require drupal/leaflet_layers

With that command, the Leaflet and Geofield modules will be downloaded too.

And then, you should install Leaflet Layers module via Drupal UI or Drush. This operation will also install Leaflet and Geofield modules too.

Now you can go to /admin/structure/leaflet_layers page, in order to manage and configure your Map bundles and Map layers.

Map layers
  • You can manage your map layers on this screen. To create a new layer, click on Add Map layer.
  • Give label to your layer. In this example, label is chosen as Artisanal mining site visits in North-West Tanzania.
  • Type down a clear description.
  • Choose your layer type. In this example, type is chosen as Overlay Layer.
  • Select your map type. In this example, type is selected as WMS.
  • Fill your WMS properties. In this example, selected properties from International Peace Information Service (IPIS) GeoServer Demo Server are listed below:
  • URL Template: http://geo.ipisresearch.be/geoserver/public/wms
  • Layers: public:tza_mines_curated_all_opendata_p_ipis
  • Format: image/png
  • Transparent: true
  • Click Save to create your map layer.
Leaflet Layers Form
This image is generated by ressa, using Leaflet Layers module.
Map bundles
  • You can manage your map bundles of your map layers on this screen. To create new bundle, click on Add Map bundle.
  • Give label to your bundle. In this example, bundle is chosen as Tanzania.
  • Enable the base layers and overlay layers you want on this bundle.
  • Tune the settings.
  • Click Save to create your map bundle.
Now you can start using your bundle on geofields and leaflet views.

ToDo: Add documentation based on the updated README file, see also #3374465: Document Leaflet 10.x features.

Tags

Help improve this page

Page status: No known problems

You can: