我正在使用以下代码生成带圆圈的地图;
http://jsbin.com/OTaKEDor/2/edit
<script src="http://d3js.org/d3.v3.min.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.3.9/d3.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script type='text/javascript' id='lt_ws' src='http://localhost:52656/socket.io/lighttable/ws.js'></script>
<div id="map" style="width: 100%; height: 100%; position: relative;" class="leaflet-container leaflet-fade-anim" tabindex="0">
</div>
<script>
var map = L.map('map').setView([51.82, 5.861], 11);
L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: ''
}).addTo(map);
var data = [ [5.861797,51.822823],[5.861843,51.822815],[5.5102863,51.78242],[5.8564305,51.821033],[5.859349,51.822502] ];
var plotData = data.map( function( coord ){
return map.latLngToLayerPoint( [ coord[1], coord[0] ] );
});
var svg = d3.select( map.getPanes().overlayPane ).append("svg"),
g = svg.append("g").attr("class", "leaflet-zoom-hide");
g.selectAll("circle").data( plotData ).enter().append("circle")
.attr("cx", function(d){ return d.x; } )
.attr("cy", function(d){ return d.y; } )
.attr("r", 25)
.style("fill", "black");
</script>
我将坐标映射到传单,以便将其放置在正确的位置。问题是圆圈被放置在传单地图上的 svg 上,google devtools 证实了这一点,但他们没有得到正确的属性,他们仍然不可见。
见截图;
有什么我忘记做的吗?