我正在尝试加载我的自定义 topojson 文件,但出现此错误:
无法读取未定义的属性“类型”
来自 topojson.min.js v1.6.9 中的第 219 行
返回 o.type === "GeometryCollection" ?{
我正在使用 d3 v3.5.3 和 topojs v1.6.9,因为我无法让更新的版本与我的自定义 topojson 文件一起使用。
<script src="d3.min.3.5.3.js"></script>
<script src="d3-geo-projection.min.js"></script>
<script src="topojson.min.1.6.9.js"></script>
<script src="datamaps.usa.min.js"></script>
<script>
var map = new Datamap({
element: document.getElementById('container'),
geographyConfig: {
dataUrl: 'Utah_Municipalities_custom.topojson'
},
scope: 'custom',
setProjection: function(element, options) {
var projection, path;
// Utah Central
projection = d3.geo.conicConformal()
.parallels([39 + 1 / 60, 40 + 39 / 60])
.rotate([111 + 30 / 60, 0]);
path = d3.geo.path()
.projection( projection );
return {path: path, projection: projection};
}
});
</script>
</body>
</html>
Utah_Municipalities_custom.topojson
{"type":"Topology","objects":{"Municipalities.gdb":{"type":"GeometryCollection","geometries":[{"type":"MultiPolygon","arcs":[[[0,1,2,3,4,5,6,7,8]]],"properties":{"COUNTYNBR":"06","NAME":"Farmington","COUNTYSEAT":1,"SHORTDESC":"FARMINGTON","UPDATED":"2018/10/05 00:00:00","FIPS":"24740","ENTITYNBR":3050,"SALESTAXID":"017","IMSCOLOR":3,"MINNAME":"Farmington","POPLASTCENSUS":18752,"POPLASTESTIMATE":22566,"GNIS":"1441004","Shape_Length":31551.51123429135,"Shape_Area":25990884.690499976}},
{"type":"MultiPolygon","arcs":[[[9]]],"properties":{"COUNTYNBR":"01","NAME":"Minersville","COUNTYSEAT":0,"SHORTDESC":"MINERSVILLE","UPDATED":"2012/04/02 00:00:00","FIPS":"50590","ENTITYNBR":3030,"SALESTAXID":"009","IMSCOLOR":3,"MINNAME":"Minersville","POPLASTCENSUS":921,"POPLASTESTIMATE":869,"GNIS":"1430376","Shape_Length":23283.92651941338,"Shape_Area":5645426.963867947}},
{"type":"MultiPolygon","arcs":[[[10]]],"properties":{"COUNTYNBR":"22","NAME":"Francis","COUNTYSEAT":0,"SHORTDESC":"FRANCIS","UPDATED":"2016/04/29 00:00:00","FIPS":"26940","ENTITYNBR":3020,"SALESTAXID":"013","IMSCOLOR":2,"MINNAME":" ","POPLASTCENSUS":1094,"POPLASTESTIMATE":1258,"GNIS":"1428080","Shape_Length":27357.49743179958,"Shape_Area":6733236.332748903}},
etc...
我猜我的 topojson 文件可能有问题,或者我可能需要弄清楚如何使用更新版本的 topojson 或其他东西创建这个地图......