如何在d3中以零投影放置经纬度?

时间:2018-10-12 11:30:23

标签: d3.js geo

我正在尝试使用d3使用预先投影的topojson绘制一些纬度和经度点。

这是我创建预先投影的topojson的方式

geoproject "d3.geoMercator().fitSize([960, 500], d)" < india.json > source.json
geo2topo -q 1e5 source.json > source.topojson

使用上述topojson,我可以完美地绘制地图,但是我不确定如何在地图上放置经纬度点。

这是我的代码。

   var india = topojson.feature(indTopo, indTopo.objects.source);

    var proxyProjection = d3.geoIdentity()
            .fitExtent([[0, 0], [width, height]], india);

    var path = d3.geoPath().projection(proxyProjection);

    svg.append("g")
        .attr("class", "states")
        .selectAll("path")
        .data(india.features)
        .enter().append("path")
        .attr("fill", "gray")
        .attr("d", path);

    svg.append("circle")
        .attr("r", 5)
        .attr("cx", point[0])
        .attr("cy", point[1]);

    //for lat-long to xy

    var mercator = d3.geoMercator()
    .fitSize([width,height], india);

   var point = mercator([80.2707, 13.0827]);

但是它没有按预期工作。

0 个答案:

没有答案