mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Generate warning when `setWorldview()` is paired with a filter expression

Open melanieimfeld opened this issue 2 years ago • 0 comments

Motivation

We now have a method to set the worldview in our SDKs. This method is part of pattern that diverges from how we previously set worldviews - by using a filter expression in the style. As a result, using setWorldview() paired with a style filter expression will lead to undesired visual results, such as missing borders. While in new styles we can build in tools to remove the filter expression, we cannot change old styles retroactively that still contain these filter expressions.

This solution proposes that when a user wishes to use setWorldview() in their implementation and a filter expression is set at the same time, a warning is generated by the SDK indicating to the user that a filter expression was set in the style.

The full proposal across map styles, Mapbox Studio and the SDKs was outlined in a separate document.

Design Alternatives

  • Do nothing: it may be difficult for users to understand why using SDK methods to set the worldview leads to unexpected results. This will affect a majority of users, because most styles use filter expressions to set worldviews.
  • One alternative that seems rather brittle, but does not require to parse the stylesheet, would be to check if the style is using an old core template and generate a warning if an old template is detected (tbd what property, but id in the stylesheet could be used).

Mock-Up

The design would entail a simple warning when users make use of setWorldview(), indicating that the filter expression in the style needs to be removed.

Implementation

TBD

melanieimfeld avatar Jul 06 '22 00:07 melanieimfeld