Skip to content

Fix for layer not found error in featuresAt function#1194

Merged
stepankuzmin merged 2 commits intomapbox:mainfrom
caldwellc:main
Aug 21, 2023
Merged

Fix for layer not found error in featuresAt function#1194
stepankuzmin merged 2 commits intomapbox:mainfrom
caldwellc:main

Conversation

@caldwellc
Copy link
Contributor

Fixes #1183

Updated fetures_at.js's featuresAt function to verify a style layer exists before adding it to queryParam.layers for the map.queryRenderedFeatures function. The mapbox-gl-draw style layers are removed during a map.setStyle call and are not added back until the data event (with type of style) is received. If the featuresAt function includes missing styles, the map.queryRenderedFeatures function will fire an error (https://github.com/mapbox/mapbox-gl-js/blob/11ea4f82e2d04041ef33339ac51909e876eed910/src/style/style.js#L1111C1-L1112C1)

Updated test/utils/create_map.js mock of mapbox-gl-js's map to include a very basic style layer management.

Updated features_at.test.js to better mock the source/style handling of mapbox-gl-js so that a test case could be added to demonstrate this fix.

…s exist before querying against them. updated existing test cases to account for this check and added a new test case to ensure missing layers are not included in the queryRenderedFeatures call.
@stepankuzmin
Copy link
Contributor

Hi @caldwellc,

Thanks for the contribution! Overall this looks good to me, just one minor nit.

@stepankuzmin stepankuzmin merged commit ff3dc5d into mapbox:main Aug 21, 2023
@lemmingapex
Copy link

Any ideas when we can expect a 1.4.3 release @stepankuzmin? Thanks!

@stepankuzmin stepankuzmin mentioned this pull request Sep 21, 2023
@stepankuzmin
Copy link
Contributor

Hi @lemmingapex. I just published v1.4.3 https://github.com/mapbox/mapbox-gl-draw/releases/tag/v1.4.3

danielsippel added a commit to danielsippel/mapbox-gl-draw that referenced this pull request Apr 17, 2024
danielsippel added a commit to danielsippel/mapbox-gl-draw that referenced this pull request Apr 18, 2024
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.

map.setStyle() followed by mouse event sometimes causes layer not found error

3 participants