如何使用mapbox的“大小写"嵌套属性的表达式? [英] How to use mapbox "case" expresion on nested properties?

查看:130
本文介绍了如何使用mapbox的“大小写"嵌套属性的表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用嵌套值以使用用例==运算符?像这样:

How to use nested value in order to use case == operator? Something like:

this.map.setPaintProperty("somelayer", "fill-color",
        ["case",
          ["==", ["properties:some_prop"], someval],
          "#34c0dd",
          "#499bbc"]

其中属性是dict:

properties = {
some_prop: 1,
some_prop2: 2,
// and so on
}

我尝试了["properties.some_prop"]和["properties"]["some_prop"],但效果不佳.

I have tried ["properties.some_prop"] and ["properties"]["some_prop"] and that does not work as well.

以及如何打印该mapbox查询,例如console.log或其他内容?

And how to print that mapbox query like console.log or something?

推荐答案

如果properties只是GeoJSON对象上的常规properties字段,那么您无需明确提及它-所有这些字段都可以直接访问:

If properties is just the regular properties field on a GeoJSON object, then you don't mention it explicitly - all those fields are just accessed directly:

this.map.setPaintProperty("somelayer", "fill-color",
    ["case",
        ["==",  ["get", "some_prop"], someval], "#34c0dd",
         "#499bbc"
    ]);

假设#499bbc是您想要的默认颜色.

Assuming #499bbc is the default colour you want.

这篇关于如何使用mapbox的“大小写"嵌套属性的表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆