Skip to content

Serialize imageoverlays in query result formats#920

Merged
JeroenDeDauw merged 1 commit into
masterfrom
fix/imageoverlays-in-semantic-query-results
Jul 14, 2026
Merged

Serialize imageoverlays in query result formats#920
JeroenDeDauw merged 1 commit into
masterfrom
fix/imageoverlays-in-semantic-query-results

Conversation

@JeroenDeDauw

@JeroenDeDauw JeroenDeDauw commented Jul 14, 2026

Copy link
Copy Markdown
Member

Fixes #919

MapPrinter converted lines, polygons, circles and rectangles into JSON-ready arrays, but not imageoverlays. The parameter was still accepted and parsed into ImageOverlay objects, which have no public properties, so each one serialized to {} and the map data ended up containing "imageoverlays":[{}]. The Google Maps JS then dereferenced properties.sw.lat on that empty object and threw, so the map did not render at all.

imageoverlays therefore never worked in any query result format. That includes #compound_query, which passes its parameters straight through to MapPrinter and needs no changes of its own.

Only the Google Maps service defines the parameter, so the conversion is guarded by a key check, the same way DisplayMapRenderer guards it for #display_map.

The regression test was seen failing on master (emitting "imageoverlays":[{}]) before the fix was written. Mutation testing confirms both branches are covered: removing the new block fails only the new test, while dropping the key check fails the Leaflet and default-format tests with Undefined array key, so the guard is load-bearing rather than defensive padding.

Out of scope

Three related things this deliberately does not touch:

  • Leaflet support for imageoverlays (Implement imageBounds to make image layers usable #651). The parameter remains Google Maps only. This PR just makes it behave in #ask the way it already behaves in #display_map.
  • The stray "imageoverlays":null on Leaflet maps. DisplayMapRenderer::handleShapeData() takes &$params['imageoverlays'] unconditionally, so on Leaflet, where the key does not exist, PHP's reference semantics create it, and every Leaflet map ships a meaningless "imageoverlays":null. Harmless today since the Leaflet JS never reads it, and unrelated to the crash fixed here. It would become a real bug the moment Implement imageBounds to make image layers usable #651 lands.
  • The Cargo output path, which may have the same defect more broadly. CargoOutputBuilder inherits the mapping service's parameter definitions but contains no elementToJson call at all, so format=map in Cargo looks like it would emit [{}] for every shape type, not just imageoverlays. Not verified and not reproduced, so no issue filed. Worth a look.

AI-authored — Claude Code, Opus 4.8 (max); one-line ask from @JeroenDeDauw to fix a bug it had diagnosed earlier in the session, no redirections; diff not yet human-reviewed; regression test seen failing then passing, 4 mutations all caught, full Maps PHPUnit suite green locally (264 tests), CI green including PHPStan, code style and QUnit.

Fixes #919

MapPrinter converted lines, polygons, circles and rectangles into JSON-ready arrays, but not imageoverlays. The parameter was still accepted and parsed into ImageOverlay objects, which have no public properties, so each one serialized to {} and the map data ended up containing "imageoverlays":[{}]. The Google Maps JS then dereferenced properties.sw.lat on that empty object and threw, so the map did not render at all.

imageoverlays therefore never worked in any query result format. That includes #compound_query, which passes its parameters straight through to MapPrinter and needs no changes of its own.

Only the Google Maps service defines the parameter, so the conversion is guarded by a key check, the same way DisplayMapRenderer guards it for #display_map.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JeroenDeDauw
JeroenDeDauw marked this pull request as ready for review July 14, 2026 15:00
@JeroenDeDauw
JeroenDeDauw marked this pull request as draft July 14, 2026 15:05
@JeroenDeDauw
JeroenDeDauw marked this pull request as ready for review July 14, 2026 15:05
@JeroenDeDauw
JeroenDeDauw merged commit 8423dd0 into master Jul 14, 2026
8 checks passed
@JeroenDeDauw
JeroenDeDauw deleted the fix/imageoverlays-in-semantic-query-results branch July 14, 2026 15:05
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.

imageoverlays is not serialized in query result formats, breaking the map

1 participant