0

我正在尝试基于命名地图可视化我们 CartoDB 帐户中的私有数据集。命名映射已创建并存在(使用 https://{username}/api/v1/map/named?api_key={api-key} 测试)。

config.json 就像:

{
  "version": "0.0.1",
  "name": "deichbreschen_named_map",
  "auth": {
    "method": "token",
    "valid_tokens": [
        "our_token"
    ]
  },
  "layergroup": {
    "layers": [{
      "type": "cartodb",
      "options": {
        "cartocss_version": "2.1.1",
        "cartocss": "#deichbreschen_netz_copy{polygon-fill:#FFFFB2;polygon-opacity:.8;line-color:#FFF;line-width:.5;line-opacity:1}#deichbreschen_netz_copy [h<=10.000000]{polygon-fill:red}#deichbreschen_netz_copy [h<=9.500000]{polygon-fill:#ff0a00}#deichbreschen_netz_copy [h<=9.000000]{polygon-fill:#ff1500}#deichbreschen_netz_copy [h<=8.500000]{polygon-fill:#ff1f00}#deichbreschen_netz_copy [h<=8.000000]{polygon-fill:#ff2a00}#deichbreschen_netz_copy [h<=7.500000]{polygon-fill:#ff3500}#deichbreschen_netz_copy [h<=7.000000]{polygon-fill:#ff3f00}#deichbreschen_netz_copy [h<=6.500000]{polygon-fill:#ff4a00}#deichbreschen_netz_copy [h<=6.000000]{polygon-fill:#f50}#deichbreschen_netz_copy [h<=5.500000]{polygon-fill:#ff5f00}#deichbreschen_netz_copy [h<=5.000000]{polygon-fill:#ff6a00}#deichbreschen_netz_copy [h<=4.500000]{polygon-fill:#ff7400}#deichbreschen_netz_copy [h<=4.000000]{polygon-fill:#ff7f00}#deichbreschen_netz_copy [h<=3.500000]{polygon-fill:#ff8a00}#deichbreschen_netz_copy [h<=3.000000]{polygon-fill:#ff9400}#deichbreschen_netz_copy [h<=2.500000]{polygon-fill:#ff9f00}#deichbreschen_netz_copy [h<=2.000000]{polygon-fill:#fa0}#deichbreschen_netz_copy [h<=1.950000]{polygon-fill:#f8a506}#deichbreschen_netz_copy [h<=1.900000]{polygon-fill:#f2a10c}#deichbreschen_netz_copy [h<=1.850000]{polygon-fill:#eb9d13}#deichbreschen_netz_copy [h<=1.800000]{polygon-fill:#e59919}#deichbreschen_netz_copy [h<=1.750000]{polygon-fill:#df941f}#deichbreschen_netz_copy [h<=1.700000]{polygon-fill:#d89026}#deichbreschen_netz_copy [h<=1.650000]{polygon-fill:#d28c2c}#deichbreschen_netz_copy [h<=1.600000]{polygon-fill:#cc8832}#deichbreschen_netz_copy [h<=1.550000]{polygon-fill:#c58339}#deichbreschen_netz_copy [h<=1.500000]{polygon-fill:#bf7f3f}#deichbreschen_netz_copy [h<=1.450000]{polygon-fill:#b87b46}#deichbreschen_netz_copy [h<=1.400000]{polygon-fill:#b2774c}#deichbreschen_netz_copy [h<=1.350000]{polygon-fill:#ac7252}#deichbreschen_netz_copy [h<=1.300000]{polygon-fill:#a56e59}#deichbreschen_netz_copy [h<=1.250000]{polygon-fill:#9f6a5f}#deichbreschen_netz_copy [h<=1.200000]{polygon-fill:#966}#deichbreschen_netz_copy [h<=1.150000]{polygon-fill:#92616c}#deichbreschen_netz_copy [h<=1.100000]{polygon-fill:#8c5d72}#deichbreschen_netz_copy [h<=1.050000]{polygon-fill:#855979}#deichbreschen_netz_copy [h<=1.000000]{polygon-fill:#7f557f}#deichbreschen_netz_copy [h<=0.950000]{polygon-fill:#795085}#deichbreschen_netz_copy [h<=0.900000]{polygon-fill:#724c8c}#deichbreschen_netz_copy [h<=0.850000]{polygon-fill:#6c4892}#deichbreschen_netz_copy [h<=0.800000]{polygon-fill:#654399}#deichbreschen_netz_copy [h<=0.750000]{polygon-fill:#5f3f9f}#deichbreschen_netz_copy [h<=0.700000]{polygon-fill:#593ba5}#deichbreschen_netz_copy [h<=0.650000]{polygon-fill:#5237ac}#deichbreschen_netz_copy [h<=0.600000]{polygon-fill:#4c32b2}#deichbreschen_netz_copy [h<=0.550000]{polygon-fill:#462eb8}#deichbreschen_netz_copy [h<=0.500000]{polygon-fill:#3f2abf}#deichbreschen_netz_copy [h<=0.450000]{polygon-fill:#3926c5}#deichbreschen_netz_copy [h<=0.400000]{polygon-fill:#32c}#deichbreschen_netz_copy [h<=0.350000]{polygon-fill:#2c1dd2}#deichbreschen_netz_copy [h<=0.300000]{polygon-fill:#2619d8}#deichbreschen_netz_copy [h<=0.250000]{polygon-fill:#1f15df}#deichbreschen_netz_copy [h<=0.200000]{polygon-fill:#1911e5}#deichbreschen_netz_copy [h<=0.150000]{polygon-fill:#130ceb}#deichbreschen_netz_copy [h<=0.100000]{polygon-fill:#0c08f2}#deichbreschen_netz_copy [h<=0.050000]{polygon-fill:#0604f8}#deichbreschen_netz_copy [h<=0.000000]{polygon-fill:#00f}",
        "sql": "SELECT * FROM deichbreschen_polygon_multitimestamp",
        "interactivity": ["cartodb_id", "date", "h", "id"]
      }
    }]
  }
}

现在在 JavaScript 中,我尝试以这种方式展示它:

  var layerSource = {
      type: "torque",
      options: {
        auth_token: "our_token",
        user_name: "our_user",
        tile_style: css,
        named_map: {
          name: "deichbreschen_named_map"
        }
      }
  };

  cartodb
    .createLayer(map, layerSource)
    .addTo(map)
    .on("done", function(layer) {
      // add time slider on change     
      map.addLayer(layer);
    })
    .on("error", function(err) {
      console.log("some error occurred: " + err);
    });

但我收到一个错误: 从命名地图渲染返回的扭矩层时出错

我做错了什么,有人可以提供一个简单的例子来说明我如何编写 Torque CSS 来随着时间的推移呈现分类多边形?

Torque.js 仍然不支持多边形吗?这可能是原因吗?

想象一下,在我的源层中,我有一个带有双值的字段 h 并使用颜色代码定义了类中断:

h < 1.00 #XXYYZZ h < 2.00 #AABBCC ...

这甚至可以通过扭矩实现吗?

4

1 回答 1

0

Torque 不(并且很可能永远不会)支持多边形或线图层,它仅适用于点数据集。

免责声明:我在 CARTO 工作。

于 2018-05-07T15:39:14.447 回答