Jump to content

ICT:Drupal Leaflet initial centering setting

From Costa Sano MediaWiki
Revision as of 12:48, 8 March 2026 by Mngr (talk | contribs) (Created page with "= Setting a Default Center and Zoom for the Leaflet Widget (Drupal 11) = == Overview == When using the Leaflet widget in ''Manage form display'' (e.g., for a PLACE content type), the map may open centered on latitude 0, longitude 0 (the Gulf of Guinea). This happens when no default coordinates are configured. Drupal 11 no longer provides global Leaflet map presets, so the correct place to set the initial map center and zoom is inside the widget settings of the geoloc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Setting a Default Center and Zoom for the Leaflet Widget (Drupal 11)

Overview

When using the Leaflet widget in Manage form display (e.g., for a PLACE content type), the map may open centered on latitude 0, longitude 0 (the Gulf of Guinea). This happens when no default coordinates are configured.

Drupal 11 no longer provides global Leaflet map presets, so the correct place to set the initial map center and zoom is inside the widget settings of the geolocation field.

This page documents how to configure a stable, Belgium‑centered default view.

Steps

  1. Navigate to:
 Structure → Content types → PLACE → Manage form display
  1. Locate the geolocation field that uses the Leaflet widget.
  2. Click the ⚙️ Settings icon next to the widget.
  3. In the widget configuration dialog, set:
 * Default latitude: 50.85
 * Default longitude: 4.35
 * Default zoom: 8
  1. Save the widget settings.
  2. Save the form display.

The following coordinates provide a balanced, country‑level view of Belgium:

Setting Value Notes
Default latitude 50.85 Centers on Brussels
Default longitude 4.35 Suitable for whole‑Belgium view
Default zoom 8 Shows Belgium clearly without zooming too far in

Result

When creating or editing PLACE content, the Leaflet widget will now open centered on Belgium instead of the default (0,0). This improves usability and provides a predictable, historian‑friendly starting point.

Notes

  • These settings apply only to the form widget, not to Leaflet maps used in Views.
  • If the field already contains coordinates, the widget will center on the stored value instead.
  • No custom code or map presets are required for this solution.