Add token support for each map definition

Created on 6 August 2025, 3 months ago

Feature request

The leaflet_maptiler module provides the ability to print a map within a text(WYSISWYG) field based on a token.
The leaflet module is responsible for all the map definitions (map definitions are build based on the following hooks leaflet_map_info() or the leaflet_map_info_alter()), so i believe it would be better to move this feature to the leaflet module. The Leaflet Layers module make it possible to define map bundles through the UI. These map info's are also included.

Proposed resolution

Provide one token per map. An example of the token structure is shown below.

[leaflet:map:OSM Mapnik:lat_lng_zoom_height:?]

Explantion:

  1. This will print a map based on the "OSM Mapnik" map info
  2. ? => can be replaced by the following arguments (latitude+longitude+zoom+height)

List of tokens:

Results:

Feature request
Status

Active

Version

10.2

Component

Code

Created by

🇧🇪Belgium p-neyens

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

Comments & Activities

  • Issue created by @p-neyens
  • @p-neyens opened merge request.
  • 🇧🇪Belgium p-neyens

    Here also a .patch version for the 10.2.x

  • 🇮🇹Italy itamair

    Thanks @p-neyens for opening all this ...
    and also thanks for mentioning the leaflet_maptiler module (by the way ... please correct your original link to that, because it is wrongly pointing to the leaflet_layers module itself).
    Thanks to this I checked and verified how easy is to integrate MapTiler layers in the Leaflet module itself, and without that leaflet_maptile module. I added some more clear examples / guides to this in the leaflet.api.php file with this last commit:
    https://git.drupalcode.org/project/leaflet/-/commit/9d8b1047467059bdaffe...
    and also implemented those 2 addiotnal Base layers in the the Leaflet module Live Demo page here:
    https://www.geodemocracy.com/drupal_geofield_stack_demo/web/geoplaces-ma...
    (@see the attached screenshot also)

    For what concerns the token support x map definition ... well, I am not convinced that this is something that the Leaflet module should be really in charge of.
    I can see that MR !62 is still in Draft state, then I assume your is still a WIP.
    BUT it looks it copes some user case very singular and specific and not very aligned with the Leaflet module scope, strictly related with Drupal content, and Geofield provided with.

    The Feature Request that is here proposed is instead going to embed and render a Leaflet Map that doesn't rely on any Drupal content, but just centred on an hard coded location and also provided with a marker not related with any Drupal entity/content.
    Very singular ...

    In my opinion a better solution for embedding a Drupal Leaflet Map (View) in a text field would be to rely on the following existing modules:
    - Insert View: https://www.drupal.org/project/insert_view
    - Advanced Insert View: https://www.drupal.org/project/insert_view_adv
    that both support arguments/contextual_filter, and that would render (and centre/point/ to) some existing Drupal content/entity.
    Also these solution would embed Leaflet Maps fully featured with possibile Popups Tooltips and even custom & dynamic Markers or Geometries styles (that the here proposed solution by token support would of course lack ... ).

    In the end ...
    feel free to complete your MR !62 solution and let us know when completely done, and please properly tested and documented.
    Eventually integrate all this with your stronger motivations, that could eventually definitely sell your feature into the Leaflet module.
    In the end this could anyway be a reference for some more subscription and some more custom and singular integration.

  • 🇧🇪Belgium bdeclerc Brussels

    Hi, I'm the architect for our Fast2Web/Openfed platform which used Maptiler before and I was the one requesting the functionality.

    The main reason for us for the basic "Token" functionality was to be able to integrate such a map into text _without_ having to set up CMS structure (content entity with geofield, views) - typically it's being used for sites where there's a need to include a single map (e.g. on the contact page) rather than for sites that need to manage multiple maps/content items with maps).

    When customers have more complex requirements, the proposed token would not be the right approach certainly, and the intention was not to have it replace more fully featured options like the ones you're suggesting.

Production build 0.71.5 2024