This bug was initially filed as mapbox/mapbox-gl-js#7019 but I'm moving it here because the bug is in the plugin.
When you change a map's style, the route feature is removed causing this line to throw the error Error: The layer 'directions-route-line-alt' does not exist in the map's style and cannot be queried for features.
|
const features = this._map.queryRenderedFeatures(e.point, { |
|
layers: [ |
|
'directions-route-line-alt', |
|
'directions-route-line', |
|
'directions-origin-point', |
|
'directions-destination-point', |
|
'directions-hover-point' |
|
] |
|
}); |
Steps to Trigger Behavior
- Add directions route to map
- Change base map style
- Move mouse around the map
Link to Demonstration
https://plnkr.co/edit/M8mj1WTH1KjDa1dhiUKw?p=preview
Expected Behavior
The plugin should be able to handle this situation so that no errors are thrown.
Actual Behavior
Errors are thrown.
cc @mikeomeara1
This bug was initially filed as mapbox/mapbox-gl-js#7019 but I'm moving it here because the bug is in the plugin.
When you change a map's style, the route feature is removed causing this line to throw the error
Error: The layer 'directions-route-line-alt' does not exist in the map's style and cannot be queried for features.mapbox-gl-directions/src/directions.js
Lines 304 to 312 in 31c7911
Steps to Trigger Behavior
Link to Demonstration
https://plnkr.co/edit/M8mj1WTH1KjDa1dhiUKw?p=preview
Expected Behavior
The plugin should be able to handle this situation so that no errors are thrown.
Actual Behavior
Errors are thrown.
cc @mikeomeara1