无法在地图上绘制路径

时间:2019-01-30 15:36:23

标签: reactjs typescript d3.js

const flightPath = {
    type: "FeatureCollection",
    features: [
        {
            type: "Feature",
            geometry: {
                type: "LineString",
                coordinates: [
                    [-87.6862308732, 41.8372950615],
                    [-118.408500088, 34.1182277898]
                ]
            },
            properties: {}
        }
    ]
};

我具有上面的geojson,我想沿着测湿器投影渲染路径,但似乎没有渲染。

这里有更多相关代码

const projection: GeoProjection = geoMercator();
const path = geoPath().projection(projection);

mapSelection
            .selectAll("path")
            .data(flightPath.features)
            .enter()
            .append("path")
            .attr("d", path as any)
            .attr("stroke", "black")
            .attr("stroke-width", "5px");

这是相关要点https://gist.github.com/fc373745/a88702de093f1306e6e02fef72fbf2e7

0 个答案:

没有答案