d3 - geo 读取csv 并且在地图上进行显示. 例子:显示中国地图上的机场 MultiPoint, path, geo_json geojson , coordinates

访问量: 1096

如下面代码所示

         /*
          // read and print all the airports
          d3.csv('static/china_airports.csv').then( (csv_line) => {

            let airports = csv_line.map((x) => {
              return [x.longitude, x.latitude]
            })
            let final_geo_points = { type: "MultiPoint", coordinates: airports}

            console.info("== airports: ", airports)
            console.info("== final_geo_points: ", final_geo_points)
            // == path(final_geo_points):  M285.07451168140926,215.7361161012281m0,4.5a4.5,4.5 0 1,1 0,-9a4.5,4.5 0 1,1 0,9zM264.5454948247849,113
            console.info("== path(final_geo_points): ", path(final_geo_points))
            svg.append("path")
                .attr("d", path(final_geo_points))
                .attr('fill', 'blue')
                .attr("stroke", "blue")
                .attr("stroke-width", 0.1)
          })
          */

订阅/RSS Feed

Subscribe