Drupal module
The iframe plugin and the neighbourhood text as Drupal blocks and field formatters: map, points of interest, travel times and a written, indexable description of the neighbourhood on the pages of your property content type, configured from Drupal instead of URL parameters. A light wrapper, no JavaScript of its own.
Install
The module is yatmo_map, for Drupal 10.3 and 11. Install it with Composer and enable it:
composer require drupal/yatmo_map
drush en yatmo_map
Project page and releases: drupal.org/project/yatmo_map; source mirror on GitHub. Then open Configuration > Web services > Yatmo Map (/admin/config/services/yatmo-map): enter your licence key and choose your country, the language (by default the language of the page), the map defaults (layout, height, zoom, style, colour, rounded corners, pin or circle, isochrones, routes, favourite addresses) and the text defaults (paragraphs, heading level, street and city in the headings). Every block and formatter starts from these defaults and can override them.
Location of the content
The blocks find the position of the property shown on the page in the fields of your content type. In the settings, give the machine names of the fields you use; the first one that is filled wins:
- a Geofield (
field_location), the usual way to store a point in Drupal; - a latitude field and a longitude field (decimal, float or text);
- an address field (plain text, or a field of the Address module): Yatmo locates it in the selected country and remembers the result for 90 days.
Content without a location shows nothing to visitors; administrators see a notice on the page.
Blocks
In Structure > Block layout, place Yatmo map and Yatmo neighbourhood text (category Yatmo) in a region of your theme and restrict them to your property content type with the Content type condition. Each block takes its location from the content of the page, or from a fixed address or coordinates typed in the block (an agency page showing its own surroundings). The block form holds every option of the iframe plugin (layout, height, zoom, map style, accent colour, rounded corners, pin or circle, isochrones, routes, country, language) and of the text (paragraphs, heading level, street and city in the headings); anything left on Settings follows the defaults.
Field formatters
If the location is a Geofield, Manage display of the content type offers two formatters on that field: Yatmo map and Yatmo neighbourhood text, with the same options as the blocks. Use them when the map or the text belongs to the content itself (view modes, Layout Builder, Views) rather than to a region.
Neighbourhood text
The text is generated by Yatmo for the location, in the languages of the property’s country (French, Dutch and English in Belgium, for example), otherwise in English, and rendered on the server as ordinary headings and paragraphs, styled by your theme (template yatmo-map-text.html.twig, overridable). The first heading names the street, the second the city; switch both off for discreet listings. One API call per location returns every language; it is cached 30 days, and the page is rebuilt when the content or the settings change.
Service and Twig
From your own module or theme, the service yatmo_map.renderer returns render arrays:
$yatmo = \Drupal::service('yatmo_map.renderer');
$build['map'] = $yatmo->map(['entity' => $node, 'mode' => 'map-top', 'marker' => 'circle']);
$build['text'] = $yatmo->text(['address' => 'Rue de la Loi 16, 1000 Bruxelles', 'paragraphs' => 'education,shopping']);
$params = $yatmo->iframeParams(['latitude' => 50.8461, 'longitude' => 4.3664]); // for your own <iframe>
In a preprocess function, $variables['yatmo_map'] = \Drupal::service('yatmo_map.renderer')->map(['entity' => $variables['node']]); then {{ yatmo_map }} in the node template. Both templates of the module, yatmo-map-embed.html.twig and yatmo-map-text.html.twig, can be copied into your theme.
All options
Keys of the options array of map(), text() and iframeParams(); the block and formatter forms expose the same ones. Each maps to a parameter of the iframe plugin. Everything left out comes from the settings.
| Name | In | Type | Description |
|---|---|---|---|
| entity | entity | A node (or any fieldable entity) whose configured fields hold the location. Default: the node of the current page. | |
| address | string | Property address, located by the Yatmo geocoder in the selected country. Looked up once, then cached for 90 days. | |
| latitude / longitude | number | Property coordinates. Take precedence over the address and the entity. A decimal comma is accepted. | |
| country | string | Country code (BE, FR, UK...). Default: the settings. | |
| language | string | Language code (EN, FR, NL...). Default: the settings, then the language of the page. | |
| mode | string | overlay, overlay-scores, map-top, map, summary or summary-tabs. See display modes. | |
| height | string |
Pixels (560) or a CSS length (70vh). The width fills the region.
Default: 560. |
|
| zoom | integer 7-20 |
Initial zoom.
Default: 15. |
|
| map_style | integer 1-7 |
Basemap style.
Default: 1. |
|
| marker | string |
pin or circle (with circle_radius in metres, 50 to 2000) for discreet listings.
Default: pin. |
|
| accent_color | string |
Hex colour of the pin and highlights.
Default: #428BFF. |
|
| rounded | integer 0-15 |
Corner radius in pixels.
Default: 0. |
|
| isochrone | string | left, right or off. See Isochrones. | |
| route_from | string | left, right, popup or off. | |
| title | string | Accessible title of the iframe. | |
| class | string | Extra CSS classes on the wrapper. | |
| paragraphs | string or list |
Text only. Among education, shopping, publictransports, transports, tourism, cities. Default: the settings (all six).
|
|
| heading | string |
Text only. Heading level of each paragraph title, h2 to h6.
Default: h3. |
|
| street_in_title / city_in_title | 0 / 1 |
Text only. Street name in the first heading, city name in the second. Set to 0 when the exact address must stay private.
Default: 1. |
Search engines
The neighbourhood text is part of your page’s HTML, rendered on the server at each request from a 30-day cache and kept by Drupal’s page caches: search engines and AI assistants read it as part of your listing, with the key places in <strong>. The summary panel inside the map widget is not indexed, since the widget is an iframe; use both for the best of both.
Drupal versions
One module for Drupal 10.3 and later and Drupal 11 (PHP 8.1 or later). The blocks and formatters are PHP attribute plugins; the Geofield formatters only appear when the Geofield module is installed. Drupal 7 is not supported.