-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add variable binding expression example #7317
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this is the best example for let
and var
. The code is almost identical to our choropleth example but with the added overhead of declaring the variable syntax. I agree with the goal of documenting how to use the variables though. @ChrisLoer thoughts?
@@ -0,0 +1,10 @@ | |||
/*--- | |||
title: Visualize population density | |||
description: Using a [`varible binding expression`](/mapbox-gl-js/style-spec#expressions-variable-binding) to calculate and display population density. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: variable
is misspelled here
["linear"], | ||
["var", "density"], | ||
274, | ||
["to-color", "#eff3ff"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @ChrisLoer 's recent work makes the explicit cast to a color here unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the cast is necessary until #7301 has merged and is being used by the example page, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, oh yeah. I was working on that. Fridays.
<script> | ||
var map = new mapboxgl.Map({ | ||
container: 'map', // container id | ||
style: 'mapbox://styles/mapbox/streets-v9', // stylesheet location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a personal vendetta against streets-v9 in examples. The flattened road labels are 🙅♂️
🤔 Yeah I see your point although it seems like using |
I'm ok with it then. Just a couple little nits to clean up. I'll update the example to remove the explicit casts to color when I finish up the test in #7301 |
This example uses
let
andvar
expressions to demonstrate variable binding syntax. To test this out locally, you'll need to replace the url to the GeoJSON with the raw data.:)