Built with blockbuilder.org
forked from rogerfischer's block: SF Precincts
forked from anonymous's block: SF Precincts
xxxxxxxxxx
<meta charset="utf-8">
<head>
<title>San Francisco Precincts / Prop F</title>
<style>
body {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
color: #272a2f;
}
#mapcanvas {
width: 960px;
height: 600px;
margin: 10px 10px 10px 10px;
/*padding: 5px 5px 5px 5px;*/
border: 0.5px solid #555;
}
p {
margin: 10px 10px 10px 10px;
}
.precinct {
fill: #555;
}
.precinct-boundary {
fill: none;
stroke: #fff;
stroke-width: none;
}
</style>
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="mapcanvas" ></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>
<script src="https://d3js.org/queue.v1.min.js"></script>
<script>
var width = 960,
height = 600;
// PROJECTION
// SF_DOE_Precincts_20120702.prj
// You can also center the map on: -122.51494800050519,37.70813100002812 like in the TopoJSON
/*var projection = d3.geo.conicConformal()
.rotate([0, 0, 0])
.center([-122.433701, 37.767683])
.scale(235000)
.parallels([37.06666666666667, 38.43333333333333])
.translate([width / 2, height / 2])
.precision(.1);*/
// MERCATOR
var projection = d3.geo.mercator()
.center([-122.433701, 37.767683])
.scale(211000)
.translate([width / 2, 310]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("#mapcanvas").append("svg")
.attr("width", width)
.attr("height", height);
// Title inside the Map
svg.append("text")
.attr("x", "50")
.attr("y", "29")
.attr("text-anchor", "start")
.style("font-size", "16px")
.style("text-decoration", "none")
.text("San Francisco Precincts");
queue()
.defer(d3.json, 'san_francisco_precinct_20120702.topojson')
.defer(d3.csv, 'san_francisco_precinct_20120702.csv') // REF
.await(ready);
function ready(error, MAP, REF) {
if (error) throw error;
console.log(MAP)
console.log(REF)
var precincts = topojson.feature(MAP, MAP.objects.precinct);
svg.append("g")
.attr("class", "precinct")
.selectAll("path")
.data(precincts.features)
.enter()
.append("path")
.attr("d", path)
.append('svg:title').text(function(d) {
return ("GeoID: " + d.id); });
//Borders
svg.append("path")
.datum(topojson.mesh(MAP, MAP.objects.precinct, function(a, b) { return a !== b; }))
.attr("class", "precinct-boundary")
.attr("d", path);
};
</script>
<p>Let us know about your needs at <a href="https://www.datamap.io/contact">https://www.datamap.io/contact</a></p>
</html>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js
https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js
https://d3js.org/queue.v1.min.js