在地图上编辑工具提示

edit tooltip on a kartograph map

我在地图上使用 kartograph 来根据数据调整 style/tooltip,所以我关注这个展示:http://kartograph.org/showcase/choropleth/

map.addLayer('layer_0', {
  styles: {
    'stroke-width': 0.7,
    fill: function(d) {
            return color(stars[d["nuts-id"]]?
                         stars[d["nuts-id"]].total_stars:
                         0);
            },
    stroke: function(d) {
              return color(stars[d["nuts-id"]]?
                           stars[d["nuts-id"]].total_stars:
                           0).darker();
    },
  },
  tooltips: function(d) {
              return [d["nuts-id"], stars[d["nuts-id"]]?
                                    stars[d["nuts-id"]].total_stars:
                                    0];
  }
});

地图很好,现在我要编辑它。

对于我成功完成的样式:

map.getLayer('layer_0').style('fill', function(d) { ... });
map.getLayer('layer_0').style('stroke', function(d) { ... });

但是我无法编辑工具提示功能...

我试试这个解决方案:https://github.com/kartograph/kartograph.js/wiki/Tooltips 但是我收到 "map.tooltips is not defined" 错误...

我终于找到了正确的语法:

map.getLayer('layer_0').tooltips(function(d) { ... });