fix: remove MultiGeometry features from the map in removeFeature#1725
Open
jamesarich wants to merge 1 commit into
Open
fix: remove MultiGeometry features from the map in removeFeature#1725jamesarich wants to merge 1 commit into
jamesarich wants to merge 1 commit into
Conversation
addFeature rendered MultiGeometry members by recursing with feature.copy(geometry = member), so the created map objects were keyed in the IdentityHashMap by those intermediate copies rather than by the caller's feature. removeFeature(feature) then found no entry and silently removed nothing: toggling a layer containing MultiPolygon/MultiLineString/ GeometryCollection features left their polygons, polylines, and markers stranded on the map, and re-adding the layer duplicated them. Render nested geometries through a private addGeometry(geometry, feature, mapObjects) recursion instead, accumulating every created map object into the original feature's entry so removeFeature works for any geometry.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 #1722 🦕
MapViewRenderer.addFeaturerenderedMultiGeometrymembers by recursing withaddFeature(feature.copy(geometry = member)), so the created map objects were keyed in therenderedFeaturesIdentityHashMapby those intermediate copies rather than by the caller's feature.removeFeature(feature)then found no entry and silently removed nothing — toggling a layer containing MultiPolygon/MultiLineString/GeometryCollection features stranded their polygons, polylines, and markers on the map, and re-adding duplicated them. The deprecatedGeoJsonLayer/KmlLayerbridges hit the same path viaremoveLayerFromMap().Change: render nested geometries through a private
addGeometry(geometry, feature, mapObjects)recursion that accumulates every created map object into the original feature's entry, soremoveFeatureworks for any geometry shape. Pure refactor of the dispatch — per-geometry rendering logic is unchanged.Tests: two new unit tests in
MapViewRendererTest—removeFeatureon a MultiPolygon feature removes both rendered polygons, and an add/remove/add/remove cycle leaves nothing behind (previously it leaked and duplicated). Full:data:testDebugUnitTestsuite passes.fix:)Developed with AI assistance (Claude Code); the analysis, fix, and tests were reviewed and run locally by the author before submission.