Loading
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 thetypeof the layer (basewhen the definition has none, as in the Leaflet module). It is the newtypekey ofdrupalSettings.mapillary.tileLayer.getLibraries()addsleaflet/maplibre-gl-leafletonly for a vector layer, asleafletRenderMap()does, so pages with a raster base map do not load MapLibre.mapillary-leaflet-formatter.jscreates the layer by its type likeDrupal.Leaflet.prototype.create_layer():L.tileLayer()forbase,L.tileLayer.wms()forwms,L.maplibreGL()with the style URL and the attribution forvector.pitchandbearingare 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") andAGENTS.mddescribe the layer types.
Tests
MapillaryLeafletFormatterTest(Kernel): thetypeand 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 requestsservice=WMS&layers=a, a vector layer creates oneL.maplibreGLwith the style URL and the attribution and requests no tile. MapLibre needs WebGL, so the test replacesleaflet/maplibre-gl-leafletwith 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().