Support for Leaflet More Maps custom collections

Created on 2 January 2026, 20 days ago

Problem/Motivation

When using leaflet_more_maps to define custom composite map collections (those with a tilde ~ prefix, e.g., ~My-Custom-Map), the Map Bundle form in leaflet_layers displays these collections incorrectly:

  1. The collection appears as multiple individual layer entries (one for each layer in the collection)
  2. This creates noise and confusion in the layer selection UI
  3. It doesn't match the intended use case: users define composite collections to use them as a single switchable base layer option

Steps to reproduce

  1. Install leaflet_more_maps module
  2. Define a custom composite map in your theme/module using hook_leaflet_map_info_alter():
    $map_info['~My-Custom-Map'] = [
      'label' => 'My Custom Map',
      'layers' => [
        'OSM' => [...],
        'Satellite' => [...],
      ],
    ];
    
  3. OR: Use the admin interface to create a custom map
    collection (see screenshot)
  4. Go to Structure > Leaflet Layers > Map Bundles > Add
  5. Observe: Each layer from the composite appears separately in the base layers list

Expected: The composite collection should appear as a single selectable option.

Proposed resolution

Detect tilde-prefixed map keys and treat them as single composite base layer entries:

  1. In MapBundleForm::getData(): Check for ~ prefix and create one entry with layer_id: __composite__ instead of iterating through individual layers
  2. In leaflet_layers_leaflet_map_info(): When encountering __composite__ layer_id, copy all layers from the source map into the bundle

This preserves the layer switcher functionality while presenting the collection as a single manageable option in the admin UI.

Remaining tasks

  • Review patch
  • Test with various composite collection configurations
  • Commit

User interface changes

The Map Bundle edit form will show composite collections (tilde-prefixed maps) as a single row labeled "(composite)" instead of multiple rows for each individual layer.

<!-- Add before/after screenshots here -->

API changes

N/A

Data model changes

Map Bundle entities will store composite collections with a special layer_id: __composite__ value instead of individual layer IDs. This is backwards compatible - existing bundles with individual layer entries will continue to work.

Feature request
Status

Active

Version

1.1

Component

Code

Created by

🇦🇺Australia NicolasH

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024