Serialize imageoverlays in query result formats#920
Merged
Conversation
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
marked this pull request as ready for review
July 14, 2026 15:00
JeroenDeDauw
marked this pull request as draft
July 14, 2026 15:05
JeroenDeDauw
marked this pull request as ready for review
July 14, 2026 15:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #919
MapPrinter converted lines, polygons, circles and rectangles into JSON-ready arrays, but not imageoverlays. The parameter was still accepted and parsed into
ImageOverlayobjects, which have no public properties, so each one serialized to{}and the map data ended up containing"imageoverlays":[{}]. The Google Maps JS then dereferencedproperties.sw.laton 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
DisplayMapRendererguards 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 withUndefined array key, so the guard is load-bearing rather than defensive padding.Out of scope
Three related things this deliberately does not touch:
imageoverlays(Implement imageBounds to make image layers usable #651). The parameter remains Google Maps only. This PR just makes it behave in#askthe way it already behaves in#display_map."imageoverlays":nullon 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.CargoOutputBuilderinherits the mapping service's parameter definitions but contains noelementToJsoncall at all, soformat=mapin 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.