-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression engine extension points #9462
Comments
Thanks for the detailed write up @brncsk! I think my initial reaction to this is that it's likely to make GL JS significantly more complex and lead to quite a few issues as developers attempt to implement their own expressions. Implementing expressions outside of the most simple ones such as Additionally, there's a lot of existing infrastructure that may be difficult to tap into with custom expressions. For example, what's the best way to add a custom expression that uses
I'm curious what other expressions you find yourself frequently wanting to implement. We're always willing to consider external PRs adding new expressions if you're interested in contributing an expression that we don't currently have. It might also be helpful to start crowd-sourcing a list of expressions people need/want. It seems like a decent portion of your use case for custom expressions was fulfilled by implementing the All of this isn't to say this can't happen. But I think we'll need to have some discussion on the best way to do this, if we ever decide to go in this direction. For the time being though, I think we need to expend some energy on making expressions as clear to use as possible for developers before we can open up the ability to add custom ones. |
cc @ericfischer This is similar to what we're discussing separately. |
#6484 tracks a master list of expressions pending implementation. |
Thanks @asheemmamoowala, yes, this is exactly what I was hoping to do too. The specific custom operators I am wanting to add (as a client of just
|
@brncsk Out of curiosity, do you think it would be possible to write that |
A long time ago, and i don't know how far Mapbox and MapLibre have moved away from each other since then. Maybe someone wants to take the concept and the few lines of code into a fork. |
Motivation
I repeatedly find myself forking and extending
mapbox-gl
for various projects where the functionality of the readily available expressions feels lacking. This mostly involves adding ad-hoc functions to the second argument ofCompoundExpression.register()
indefinitions/index.js
.Past use cases include:
in
expression – this was implemented since)For this reason, I propose a way for end users to be able to extend the list of built-in expression functions by supplying their own Javascript (or C++, in the case of
gl-native
) implementations. This would allow the user to use the full potential of the underlying Javascript runtime to specify feature styles during render time.Similar functionality is available in mainstream desktop GIS software as well, see:
...and also in OpenLayers:
(Please note that this is orthogonal to #7010 which proposes a way to define first-class functions inside the expression language.)
Design Alternatives
mapbox-gl
is always an option for those who want to do this.Design
I do realize that you probably consciously chose not to implement this in the past, although I failed to find a write up on the exact reasons (been reading discussions in the old
mapbox-gl-function
repo etc.).Mock-Up
This is modelled after how expression functions are defined in
definitions/index.js
.Note that I'm using the type names defined in
compound_expression.js
Concepts
Another thing that makes this potentially unfeasible is that this exposes a large number of concepts, classes and types internal to mapbox-gl, such as
EvaluationContext
, the above mentioned types incompound_expression.js
etc.The text was updated successfully, but these errors were encountered: