map json works on Geojson.io but it doesnt work on dc.js choropleth map

霸气de小男生 提交于 2019-12-04 05:29:14

问题


I created geojson turkey map on geojson.io. It works on geojson.io with no trouble.But it doesnt work on dc.js choropleth map.

I checked it with us-states.json on my codes it works but my geojson map doesnt work.

Here My created geojson:

mygeojson


回答1:


Without your code, hard to answer, but the problems I have usually with dc.js choropleth is

1) not using the right selector or key for overlayGeoJson(yourJson.features, "selector", function(d) { return d.name; });

  • yourJson.features: geo json data (not topojson)
  • "selector" - name of the layer which will be used to generate css class
  • 3rd param - (optional) a function used to generate key for geo path, it should match the dimension key (eg. county name, iso of the country...

use jQuery/underscore/d3 to test your selector

2) not defining the projection (eg. mercator)

.projection(d3.geo.mercator())

3) having the wrong scale/transform Here the map is properly drawn, but not in a visible scale

.scale(something)
.translate([x, y]))

But share your code (preferably on jfiddle), so we can have a look at it



来源:https://stackoverflow.com/questions/27671784/map-json-works-on-geojson-io-but-it-doesnt-work-on-dc-js-choropleth-map

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