fix: Ensure snap points always load #193
Merged
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.
Addresses https://trello.com/c/NZrvqg7d/2055-get-snap-points-on-map-to-always-load
Currently, points are automatically generated on the assumption that vector tiles will be loaded. On slower connections, this means that snap points either do not display or do not fully display. This can be mocked in the browser by throttling your connection speed.
This PR fixes this by waiting for the map
loadend
event before triggering the generation of the snap points. Originally I was listening for the vector source'stileloadend
event but this fires for each tile load and then regenerates snap points which I imagine is both computationally expensive and could lead to inconsistent results (e.g. all snap points loading in one tile at a time).Also - some basic OL tests! Couldn't quite get around a few event dispatch issues so I'm manually calling them currently. This would be great to try and remove - possibly something to tackle when/if we add Cypress to the stack.