大佬教程收集整理的这篇文章主要介绍了javascript – d3.js在d3.geo.path中添加一个圆,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
var map = svg.append("g").attr("class","map"); var path = d3.geo.path().projection(d3.geo.albers().origin([3.4,46.8]).scale(12000).translate([590,570])); d3.json('myjsonfile.json',function(json) { map.SELEctAll('path').data(json.features).enter().append('path').attr('d',path) });
现在我想在我的svg中添加一个svg元素(一个点,一个圆圈,一个点(我不知道))及其(lat,lng)坐标.
我不知道该怎么做
@H_262_8@var map = svg.append("g").attr("class","map"); var projection = d3.geo.albers() .origin([3.4,46.8]) .scale(12000) .translate([590,570]); var path = d3.geo.path().projection(projection); d3.json('myjsonfile.json',function(json) { map.SELEctAll('path') .data(json.features) .enter().append('path').attr('d',path); // now use the projection to project your coords var coordinates = projection([mylon,mylat]); map.append('svg:circle') .attr('cx',coordinates[0]) .attr('cy',coordinates[1]) .attr('r',5); });
另外一种方法就是用点调整投影坐标:
@H_470_2@map.append('svg:circle') .attr("transform",function(d) { return "translate(" + projection(d.coordinates) + ")"; }) .attr('r',5); @H_262_8@ @H_262_8@以上是大佬教程为你收集整理的javascript – d3.js在d3.geo.path中添加一个圆全部内容,希望文章能够帮你解决javascript – d3.js在d3.geo.path中添加一个圆所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。