You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When map.setStyle() is called and a mousemove event fires, mapbox-gl-draw's event listener will run map.queryRenderedFeatures passing the layers from ctx.options.styles. However, this sometimes occurs before mapbox-gl-draw's map.on("data") event listener can add back in the missing style layers caused by the map.setStyle() function, the following error occurs:
mapbox-gl.js:31 Error: The layer 'gl-draw-polygon-fill-inactive.cold' does not exist in the map's style and cannot be queried for features.
at i.queryRenderedFeatures (mapbox-gl.js:35:133328)
at r.queryRenderedFeatures (mapbox-gl.js:35:323577)
at ot (mapbox-gl-draw.js:1:4660)
at Object.click (mapbox-gl-draw.js:1:4319)
at rt (mapbox-gl-draw.js:1:5068)
at i.mousemove (mapbox-gl-draw.js:1:22101)
mapbox-gl-js version 1.13.2
mapbox-gl-draw version 1.3.0, 1.4.2
A suggested solution might be to update the featuresAt function to filter the queryParams.layers to only use layers that exist on the map:
if (ctx.options.styles) queryParams.layers = ctx.options.styles.map(s => s.id);
…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.
* issue #1183 updated featuresAt function to check if style layers 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.
* use map.getLayer instead of map.style.getLayer. update tests.
When map.setStyle() is called and a mousemove event fires, mapbox-gl-draw's event listener will run map.queryRenderedFeatures passing the layers from ctx.options.styles. However, this sometimes occurs before mapbox-gl-draw's map.on("data") event listener can add back in the missing style layers caused by the map.setStyle() function, the following error occurs:
mapbox-gl-js version 1.13.2
mapbox-gl-draw version 1.3.0, 1.4.2
A suggested solution might be to update the featuresAt function to filter the queryParams.layers to only use layers that exist on the map:
if (ctx.options.styles) queryParams.layers = ctx.options.styles.map(s => s.id);
to
if (ctx.options.styles) queryParams.layers = ctx.options.styles.map(s => s.id).filter(id => ctx.map.style.getLayer(id) != null);
The text was updated successfully, but these errors were encountered: