Skip to content

Changing map style causes plugin to throw errors #190

@ryanhamley

Description

@ryanhamley

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

  1. Add directions route to map
  2. Change base map style
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions