Hello and thanks for this module,
Problem/Motivation
The Leaflet Maptiler module integrates Maptiler Cloud map styles with Leaflet module.
It registers its map styles via hook_leaflet_map_info(), which works correctly for Leaflet display formatters. However, Maptiler styles do not appear in the Geofield Map widget's Map type dropdown, because that dropdown is populated by the LeafletTileLayerPlugin plugin system, which is independent of hook_leaflet_map_info().
Proposed resolution
A geofield_map_leaflet_maptiler submodule, that declares leaflet_maptiler module as a dependency and implements LeafletTileLayerPlugin plugins for each configured Maptiler style.
The key challenge is that Maptiler tile URLs require a per-site API key stored in Drupal config (leaflet_maptiler.settings), whereas existing LeafletTileLayerPlugin implementations use hardcoded static URLs. The correct approach is a plugin deriver (MaptilerLayerDeriver) that reads the module config at plugin discovery time and generates one plugin definition per configured style, with the API key injected into the URL template.
This would make entries like Maptiler: Basic, Maptiler: Backdrop, etc. appear in the Geofield Map widget's Map type dropdown, selectable per field.
Remaining tasks
- Implement geofield_map_leaflet_maptiler submodule with MaptilerLayer plugin class and MaptilerLayerDeriver deriver
- Test that per-style entries appear correctly in the widget's Map type dropdown
- Test that tiles render correctly when a node is edited
User interface changes
Maptiler style options (one per configured style in leaflet_maptiler.settings) will appear in the Map type dropdown of the Geofield Map widget settings form.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | Screenshot 2026-05-19 at 23.49.04.jpg | 484.26 KB | itamair |
| #2 | Screenshot 2026-05-19 at 23.49.04.jpg | 484.26 KB | itamair |
| #2 | MapTilersLeafletTileLayerPlugins.zip | 2.57 KB | itamair |
Issue fork geofield_map-3590864
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
itamair commented@orkutmuratyilmaz
the Geofield Map module implements LeafletTileLayerPlugin plugins to add/create new Leaflet Map tiles in its Widget and its already able (with that) to support MapTiler Tiles.
Anyone could just add new LeafletTileLayerPlugin plugins such the following ones (here attached):
- MapTilerBasic.php
- MapTilerAcquerelle.php
in his own custom_module /src/Plugin/LeafletTileLayerPlugin folder.
Try them, just adjusting the custom_moudule namespace and the [maptiler_api_key],
you will see that Geofield Map Widget will implement both Basic and Acquerelle MapTiler Tiles,
as in the attached screenshots.
There is no need at all to implement any submodule that relies on the hook_leaflet_map_info() from the Leaflet module, that is a (completely) different module form the Geofield Map.
PS: Strictly speaking also the Leaflet Maptiler module would be needed as contrib module.
Leaflet module already natively support Maptiler Raster Tiles since a while ago: https://www.drupal.org/project/leaflet/issues/3591050
Anyone could generate new customised Leaflet MapTiler Tiles directly/autonomously implementing hook_leaflet_map_info() in his own custom module ...
Comment #4
orkutmuratyilmaz@itamair, thanks for detailed explanation and attached code too. It is also a great guidance too.