fix: add prop to set unique id on element & clear the featureSource unless clickFeatures is enabled#110
Merged
jessicamcinchak merged 5 commits intomainfrom Jan 14, 2022
Merged
Conversation
|
✔️ Deploy Preview for oslmap ready! 🔨 Explore the source changes: bc793a2 🔍 Inspect the deploy log: https://app.netlify.com/sites/oslmap/deploys/61e14859383fc00008694ff3 😎 Browse the preview: https://deploy-preview-110--oslmap.netlify.app |
clickFeatures is enabled
clickFeatures is enabledclickFeatures is enabled
Member
Author
Member
Author
Member
Author
DafyddLlyr
approved these changes
Jan 14, 2022
Contributor
DafyddLlyr
left a comment
There was a problem hiding this comment.
All the changes here look good and make sense to me 👍
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.
working solution:
idproperty so we can set a custom id on<my-map />element, defaults to "map" as beforeshowFeaturesAtPointis enabled, which should prevent prior query results from persisting in the layer. ifshowFeaturesAtPoint&&clickFeaturesare enabled (don't know of any prod uses of this yet), then we don't clear the source as before to allow for selecting/deselecting features on clickdugging notes:
update
index.htmlto something like this:in short: when rendering the component multiple times on a page with different props, each instance reflects the layer data of the other - some props sync unexpectedly (ie
showFeaturesAtPoint,drawMode), and others do not (featureColor, etc).expected behavior is for each instance of the component to exclusively reflects its' own props & it's own layer data based on those props (eg only the feature that intersects with its' unique lat/lng).
this can be reproduced in PlanX by selecting an address, going 'back' to change the address, and then seeing two highlighted features on the FindProperty map
things i learned:
outlineLayer,drawingLayer, etc are still shared/synced between them. Here's related threads/issues: Cloning a vector layer in Openlayers 6 openlayers/openlayers#10764 (comment), https://stackoverflow.com/questions/63267102/how-can-i-assign-a-unique-identifier-to-openlayers-layers