Working with TopoJSON and d3.js projections for mapping geospatial data.
forked from mbostock's block: U.S. Counties TopoJSON
forked from enjalot's block: WWSD #12: d3 + TopoJSON
xxxxxxxxxx
<meta charset="utf-8">
<style>
path {
fill: #ccc;
stroke: #fff;
stroke-width: .5px;
}
path:hover {
fill: red;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var projection = d3.geo.mercator()
.scale(1800)
var path = d3.geo.path()
.projection(projection);
d3.json("generalized_trail.geojson", function(error, trails) {
console.log(trails);
var extent = d3.extent(trails.features);
console.log(extent)
// var url = "https://gist.github.com/SwampGuzzler/df630651d2ecab638afbf3e59fb66186"
// d3.json(url, function(error, topology) {
// console.log('ooh');
// if (error) throw error;
// console.log("topojson", topology)
// var geojson = topojson.feature(topology, topology.objects.counties);
// console.log("geojson", geojson)
svg.selectAll("path")
.data(trails.features)
.enter().append("path")
.attr("d", path)
.attr("transform", "translate(3800,1700)")
});
</script>
https://d3js.org/d3.v3.min.js