Skip to content

[FEATURE] Add marker clustering for OpenStreetMap - #383

Merged
sfroemkenjw merged 1 commit into
mainfrom
feature/marker-clustering-osm
Oct 2, 2026
Merged

sfroemkenjw merged 1 commit into
mainfrom
feature/marker-clustering-osm

Conversation

@sfroemkenjw

Copy link
Copy Markdown
Contributor

Resolves #169

Adds marker clustering for OpenStreetMap and makes the existing clustering setting provider-independent. This is an alternative to #377: instead of a separate OSM-only FlexForm setting, the existing site setting is reused, so clustering also works via TypoScript for maps rendered through the maps2 API without a FlexForm.

Changes

Settings

  • Move site setting maps2.enableMarkerClusterer from site set Maps2 - Google Maps into Maps2 - Default Set. The key is unchanged, existing settings.yaml files keep working. It is now listed under category "Maps2 > Marker Clusterer".
  • New FlexForm field settings.markerClusterer.override in tab "Map Options" for Google Maps and OpenStreetMap: use site setting / TypoScript (default, empty), enabled, disabled. An empty value never overrides TypoScript.
  • New TypoScript setting plugin.tx_maps2.settings.markerClusterer.styleSheet (OSM only), default EXT:maps2/Resources/Public/Css/Leaflet/MarkerCluster.Default.css. Accepts EXT: and fileadmin/ paths and is included as-is via AssetCollector, no build step required. It is the OSM counterpart of markerClusterer.imagePath (GM only).

OpenStreetMap

  • Clustering via the official Leaflet.markercluster ^1.5.3 (L.markerClusterGroup). Only point markers are clustered; areas, routes and radius stay on the map directly. No clustering in edit mode.
  • showCoverageOnHover is disabled.
  • Category switching works with the cluster group.
  • Maps are initialized on DOMContentLoaded, so the cluster library is available even if only a later plugin on the page enables clustering.

Google Maps

  • Bugfix: clustering was broken since the switch to AdvancedMarkerElement (marker.getPosition is not a function). The outdated MarkerClusterer v1 is replaced by the official @googlemaps/markerclusterer ^2.6.2. A custom renderer keeps using the cluster images m1.png–m5.png of markerClusterer.imagePath.
  • The library is loaded on demand via AssetCollector in partial LoadAssets instead of page-wide page.includeJSFooterlibs, so the FlexForm option also works if clustering is disabled in TypoScript.

Build / Docs

  • build.mjs ships both vendor libraries incl. licenses.
  • Documentation (Plugins, TypoScript) and ChangeLog (13.2.0) updated.

Tested manually (TYPO3 14.3, ddev)

  • Google Maps: ~30 POIs, clusters render with the existing images, click zooms in and splits clusters, no console errors.
  • OpenStreetMap: clusters render, no coverage polygon on hover, custom styleSheet via EXT: and fileadmin/ path is loaded.
  • Rendered output checked for FlexForm override default/on/off with TypoScript on/off for both providers.

Open

  • Unit tests for SettingsHelper::prepareMarkerClusterer().
  • Version bump in ext_emconf.php on release.

🤖 Generated with Claude Code

Implement marker clustering for OpenStreetMap based on the official
Leaflet.markercluster plugin. Only point markers are clustered. The
coverage polygon on hover is disabled.

Move the site setting maps2.enableMarkerClusterer from the Google Maps
site set into the maps2 default site set, so it applies to both map
providers. The setting key is unchanged, existing site configurations
keep working.

Add a FlexForm option in tab "Map Options" to enable or disable
clustering per content element for both providers. An empty value
falls back to the site setting, so maps rendered via the maps2 API
without a FlexForm are configured by TypoScript only.

Add the TypoScript setting markerClusterer.styleSheet to replace the
cluster theme of Leaflet.markercluster with a custom CSS file. It is
the OpenStreetMap counterpart of markerClusterer.imagePath.

Replace the outdated MarkerClusterer v1 for Google Maps with the
official @googlemaps/markerclusterer library, because v1 does not
support AdvancedMarkerElement. The cluster images of imagePath are
still used. Both libraries are loaded on demand via AssetCollector.

Resolves: #169
Related: #377

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sfroemkenjw
sfroemkenjw merged commit 4cc27f6 into main Oct 2, 2026
6 checks passed
@sfroemkenjw
sfroemkenjw deleted the feature/marker-clustering-osm branch October 2, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Clustering Feature for OpenStreetMap

1 participant