🏠 back to Observable

Why does this mapbox map (viewof) react on the language variable

i do not understand where the binding to the language variable comes in this notebook.

thx
newbie

The third cell of your notebook consists of this code:

map.setLayoutProperty("country-label-lg", "text-field", [
  "get",
  "name_" + language
])

Note that it contains a reference to language.

The Observable parser is smart enough to know that language must be a reference to another cell, thus the Observable compiler compiles that cell into this in the downloaded code:

 main.variable(observer()).define(["map","language"], function(map,language){return(
 map.setLayoutProperty("country-label-lg", "text-field", [
   "get",
   "name_" + language
 ])

Does that answer your question?

3 Likes

thx so much @bgchen, cant believe that i did not examine the 3rd cell.

1 Like