Dzmitry Petrushenka
08/01/2022, 4:24 PMmkrussel
08/01/2022, 7:51 PMval mag1 = lt {
get("mag")
literal(2)
}
val mag2 = all {
gte {
get("mag")
literal(2)
}
lt {
get("mag")
literal(3)
}
}
val mag3 = all {
gte {
get("mag")
literal(3)
}
lt {
get("mag")
literal(4)
}
}
val mag4 = gte {
get("mag")
literal(4)
}
val earthQuakes = geoJsonSource("earthquakes") {
data("<https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson>")
cluster(true)
clusterRadius(80)
clusterProperty(
"mag1",
sum {
Expression.switchCase(mag1, Expression.literal(1), Expression.literal(0))
}
)
clusterProperty(
"mag2",
sum {
Expression.switchCase(mag2, Expression.literal(1), Expression.literal(0))
}
)
clusterProperty(
"mag3",
sum {
Expression.switchCase(mag3, Expression.literal(1), Expression.literal(0))
}
)
clusterProperty(
"mag4",
sum {
Expression.switchCase(mag4, Expression.literal(1), Expression.literal(0))
}
)
}
Then there is the same type of translate for all the other layer properties["something", ...]
code are expressions. So the trick is to make the first string to the expression function in the DSL.Dzmitry Petrushenka
08/02/2022, 7:05 AM