-
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
Expressions: get lookup not evaluated before passing to function #6941
Comments
Hi @rconjaerts, thanks for using Mapbox. As you've discovered, you can't intermix Mapbox GL expressions with Javascript execution in this way. In the course of constructing an expression (which takes the form of a Javascript array), you can evaluate Javascript -- for instance, including the result of You could potentially implement date parsing via a (likely very complex) expression, but it would be quite challenging. So I've added a request for support for date and time types within the expression language to #6484. Until then, the best way to accomplish what you're going for here is probably to adapt the data, supplying a field that contains a count of milliseconds-since-the-epoch directly, and using that for the comparison. |
+1 on this request. Would be immensely helpful to use DateTimes in expressions to do something like Kepler.gl's DateTime slider (http://kepler.gl/#/demo/earthquakes). |
Issue
Currently when an expression is created with a call to a function the passed arguments are not evaluated before calling that function. For example the following expression won't be evaluated as intended:
["<=", new Date(["get", "inservicedate"]).getTime(), new Date().getTime()]
The idea is that I would get the property inservicedate from my feature, create a date from it and get the time in as a number so that I can use it in my expression to filter. The issue is that ["get", "inservicedate"] doesn't get evaluated (thus not getting the property), but just passed as a parameter (array objec) to the Date() function which results in a null value.
Is this a bug or am I interpreting the docs of mapbox incorrectly? I can change this into a feature request with the following proposed solutions.
Proposed solutions
The text was updated successfully, but these errors were encountered: