【发布时间】:2014-02-13 01:14:49
【问题描述】:
我正在尝试使用 D3 和 csv 文件将点添加到谷歌地图上。我似乎能够正确读取经纬度坐标,但它们不会在地图上的任何地方绘制。
var map = new google.maps.Map(d3.select("#map").node(),
{
zoom: 11,
center: new google.maps.LatLng(39.654835520000063, -105.01942651999994),
mapTypeId: google.maps.MapTypeId.TERRAIN
});
d3.csv("data.csv", function(error, data)
{
var overlay = new google.maps.OverlayView();
overlay.draw = function() {
d3.select("circle")
.data(data)
.enter()
.append("circle")
.attr("cy", function(d)
{
return [d.longitude, d.latitude][0];
})
.attr("cx", function(d)
{
return [d.longitude, d.latitude][1];
})
.attr("r", 5)
.style("fill", "blue");
}
overlay.setMap(map);
});
【问题讨论】:
-
你需要投影坐标。你见过this example吗?
标签: google-maps csv d3.js latitude-longitude points