Leaflet.js(~version 0.7.*)의 지도에 d3.js에서 svg 요소 보기
h tp // w w. d3의 b. rg/2014/03/ぇあ fぇtー마 p우우 thd3jsー에에멘 tsーーーーー. HTML
라이브러리 파일을 로드합니다.
<link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<script src="//cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<script src="//d3js.org/d3.v3.min.js"></script>
지도를 그립니다(예: OpenStreetMap).
var map = L.map('map').setView([35.689488, 139.691706], 4);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png', {
attribution: '© ' + mapLink + ' Contributors',
maxZoom: 18,
}).addTo(map);
map._initPathRoot();

지도가 표시되었습니다.
Chrome에서 Developer Tools를 시작하면 Leaflet.js가 생성 한 div에 svg가 생성됩니다.

여기에 d3.js를 사용하여 svg 요소를 추가합니다. 우선은 편리하므로 그룹 요소를 생성합니다.
var g = d3.select("#map").select("svg").append("g");

svg에 그룹이 생성되었습니다.
데이터를 기반으로 circle을 생성하면,
var feature = g.selectAll("circle")
.data(collection.objects)
.enter().append("circle")
.style("stroke", "black")
.style("opacity", .4)
.style("fill", "red")
.attr("r", 4);

그룹 안에 cicle가 생성되었습니다.

그리고는 viewreset시에, 생성한 그룹의 정렬을 하도록(듯이) latLngToLayerPoint를 사용한 설정을 해 둡니다.
ぇ tp // // ぇ ぇ tjs. 코 m/레후오렌세. html # 마 p ゔ ぃ
map.on("viewreset", update);
update();
function update() {
feature.attr("transform",
function(d) {
return "translate("+
map.latLngToLayerPoint(d.LatLng).x +","+
map.latLngToLayerPoint(d.LatLng).y +")";
}
)
}
Reference
이 문제에 관하여(Leaflet.js(~version 0.7.*)의 지도에 d3.js에서 svg 요소 보기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/yuichy/items/f2d8e66a75e1e9200eda텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)