D3js circles on a map : Projection Issue?

纵饮孤独 提交于 2019-12-12 02:15:42

问题


Once again i'm searching for some help.

I manage to draw my map but when i attempt to add circles (stores locations from csv), my points appears in the left corner and i'm getting the following errors

> Error: <circle> attribute cx: Expected length, "NaN". Error: <circle>
> attribute cy: Expected length, "NaN". Error: <circle> attribute r:
> Expected length, "NaN".

I read many posts here in stack and i read the basic tutorial from Mike Bostock but can't manage to have my points at the right place

So i'm wondering if the projection of the circles i'm using is not the cause of this behaviour i'm seeing

Please find here my plunker

N.B : I deliberately used the same json file twice in my if function, please don't mind this point

Thank you very much for your help


回答1:


There are two things that come to mind:

  1. Your CSV headers (Lon,Lat) do not match the properties you use to center the circles (lon, lat).

  2. There is an error in your csv: 13,33.243161-8.512494999999944,Station13,1672473 (It's missing a comma).

If you think you are having problems with the projection, the easiest way to confirm this is to test a point out:

console.log(projection[0,0]); 

If you get a SVG coordinate back, your projection is likely not the issue. Instead the issue is likely with what you are feeding the projection or the inline formula that uses the data projection returns.



来源:https://stackoverflow.com/questions/42700208/d3js-circles-on-a-map-projection-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!