卡图.js如何通过路径 ID 获取元素
kartograph.js How to get element by path id?
我正在使用制图.js并且我有几个连接区域/路径的svg,我想通过着色来突出显示单击的区域,然后在另一个div上显示有关它的其他信息。当您单击新形状时,我在删除形状的突出显示时遇到问题。我怎样才能做到这一点?谢谢!
var previd=0;
var prevpath;
function mapLoaded(map) {
map.addLayer('mylayer', {
tooltips: function(d) {
return [d.watershedname,"area: "+d.area];
},
styles: {
stroke: '#aaa',
fill: '#f6f4f2'
},
click: function(d, path) {
// @path is a Raphael.element, do with it whatever you like
// @d holds the data attached to each path
//retrieve and set text to other div
$("#infoname").text(d.watershedname);
$("#infoarea").text(numberWithCommas(Math.floor(d.area))+" hectares");
//highlight the selected path
path.attr('fill', 'red');
//i'm trying to get the previous path by id here
//so i can remove the previous highlight
//doesn't work
prevpath =mylayer.getById(previd);
prevpath.attr('fill','blue');
//set the new id for later access
previd=path.attr('id');
}
});//end of add layer
}//end of mapLoaded
II 得到 ID,我使用了 Layer.getPaths({column:value});
var templayer = map.getLayer('mylayer').getPaths({watershedname:selected});
templayer.forEach(function(entry) {
entry['svgPath'].attr('fill','#f6f4f2');
});
相关文章:
- 使用angularjs中的rest调用通过id获取数据
- javascript从id获取数字
- 如何通过ID获取图层对象
- 通过jstree中的Id获取节点
- 在控制器中按ID获取XML ViewElement(MultiInput)
- node.js使用monk从数组中按id获取文档
- 如何使用API从多个IMDB ID获取电影信息
- 我的ID获取元素不起作用
- 如何通过 id 获取“this”元素并查看是否选中
- 使用类而不是 ID(通过 CLASS 而不是 ID 获取元素)
- 如何在Ember.js中使用jQuery通过id获取元素
- 使用类名按ID获取元素
- jquery模态对话框通过id获取输入类型text的值
- 通过ID获取声明性dojo数据网格
- 可以't按id获取元素
- 根据DropDown ID获取DropDownListFor的选定值
- jquery如何使用chlid id获取父元素的类
- 在iframe中通过id获取元素
- 主干模型通过ID获取JSON元素
- 在javascript中通过id获取元素,而页面上没有任何表单标记