D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ElisaDnr
Full window
Github gist
France Map
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> var svg = d3.select( "body" ) .append( "svg" ) .attr( "width", "600px" ) .attr( "height", "800px" ); // On rajoute un groupe englobant toute la visualisation pour plus tard var g = svg.append( "g" ); var path = d3.geoPath(); var projection = d3.geoConicConformal() .center([2.454071, 46.279229]) .scale(3000) .translate([300,300]); path.projection(projection); d3.json("departement.json", function(geoJSON) { var map=svg.selectAll("path").data(geoJSON.features); map.enter() .append("path") .attr("fill","white") .attr("stroke","black") .attr("d", path); console.log(map.enter()._groups[0][0]); //console.log(map.enter()[0][0].__data__.geometry) for(var i = 0; i < map.enter()._groups[0].length; i++){ console.log(map.enter()._groups[0][0].__data__.geometry) } }); /* d3.csv("caracteristiques_2016.csv", function(data){ for (i = 0; i < data.length ; i++){ // Si les coordonées ne sont pas nulles if(!("0" == 0 && data[i].long == 0)){ //On définit les lat et long de chaques marqueurs var markLat = data[i].lat; var markLong = data[i].long; markLat = parseFloat(markLat.slice(0,2) + "." + markLat.slice(2)); markLong = parseFloat(markLong.slice(0,2) + "." + markLong.slice(2)); if(L.latLngBounds(latLngs).contains([markLat,markLong])){ //On ajoute les marqueurs on conteneur dynamique m = L.marker([markLat,markLong]).bindTooltip(data[i].Num_Acc); m.num_acc= data[i].Num_Acc; m.on("mouseover", function(event){console.log(event.target.num_acc)}) markers.addLayer(m); } } } }); */ </script> </body>
https://d3js.org/d3.v4.min.js