bug: #3633821: The split viewer formatter ignores vector and WMS base layers

Closes #3633821

The split viewer formatter now shows the site's base map when the base layer is a vector or a WMS layer. Until now it requested the style URL or the WMS address as a raster tile template, so the map stayed empty and the browser logged failed tile requests. Sites with a raster base layer see no difference, and nothing needs to be done on update.

Changes

  • MapillaryLeafletSplitViewerFormatter::tileLayer() also returns the type of the layer (base when the definition has none, as in the Leaflet module). It is the new type key of drupalSettings.mapillary.tileLayer.
  • getLibraries() adds leaflet/maplibre-gl-leaflet only for a vector layer, as leafletRenderMap() does, so pages with a raster base map do not load MapLibre.
  • mapillary-leaflet-formatter.js creates the layer by its type like Drupal.Leaflet.prototype.create_layer(): L.tileLayer() for base, L.tileLayer.wms() for wms, L.maplibreGL() with the style URL and the attribution for vector. pitch and bearing are passed only when they are set, since the bridge has no pitch or bearing support. A vector layer without the library leaves the map without a base layer instead of requesting the style URL as a tile.
  • CHANGELOG.md ("Fixed") and AGENTS.md describe the layer types.

Tests

  • MapillaryLeafletFormatterTest (Kernel): the type and the conditional library for a raster, a vector and a WMS layer. The Leaflet service is replaced by a mock that returns the layer.
  • SplitViewerBaseLayerTest (FunctionalJavascript), new: a base layer requests tile images, a WMS layer requests service=WMS&layers=a, a vector layer creates one L.maplibreGL with the style URL and the attribution and requests no tile. MapLibre needs WebGL, so the test replaces leaflet/maplibre-gl-leaflet with a recorder (mapillary_leaflet_test/fake_maplibre); the other layers are real Leaflet layers. The test module gets a page (SplitViewerPageController) with the markup and settings the formatter produces, pointing to a closed local port.
  • Run locally on Drupal 11 and PostgreSQL: the Kernel class (7 tests) and the new FunctionalJavascript class (3 tests) pass; the vector and WMS tests failed before the fix. phpcs (Drupal, DrupalPractice) is clean for the changed PHP files and phpstan level 6 reports only the missing iterable value type that was already there. The full suite and Drupal 12 run in the pipeline.

Upgrade path

No schema or configuration change and no update hook. Only drupalSettings.mapillary.tileLayer gets a new key; the formatter class is final, so no other code overrides tileLayer().

Merge request reports

Loading
Loading