Commit 8fb69fa2 authored by Mike Bostock's avatar Mike Bostock
Browse files

Remove mercator examples.

Replaced by <http://bl.ocks.org/2374239>.
parent 8d331997
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.frame {
stroke: #000;
fill: none;
pointer-events: all;
}
.feature {
fill: #eee;
stroke: #ccc;
}
</style>
<script src="../../d3.js"></script>
<body>
<script>
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var projection = d3.geo.mercator()
.scale(width)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var zoom = d3.behavior.zoom()
.translate(projection.translate())
.scale(projection.scale())
.scaleExtent([height, 8 * height])
.on("zoom", move);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.call(zoom);
var feature = svg.append("path")
.attr("class", "feature");
svg.append("rect")
.attr("class", "frame")
.attr("width", width)
.attr("height", height);
d3.json("../data/world-countries.json", function(error, collection) {
feature.datum(collection).attr("d", path);
});
function move() {
var t = d3.event.translate,
s = d3.event.scale;
t[0] = Math.max(-s / 2, Math.min(width + s / 2, t[0]));
t[1] = Math.max(-s / 2, Math.min(height + s / 2, t[1]));
zoom.translate(t);
projection.translate(t).scale(s);
feature.attr("d", path);
}
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.frame {
stroke: #000;
fill: none;
pointer-events: all;
}
.feature {
fill: #eee;
stroke: #ccc;
}
</style>
<script src="../../d3.js"></script>
<body>
<script>
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var projection = d3.geo.mercator()
.scale(width)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var zoom = d3.behavior.zoom()
.translate(projection.translate())
.scale(projection.scale())
.scaleExtent([height, 8 * height])
.on("zoom", move);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.call(zoom);
var feature = svg.append("path")
.attr("class", "feature");
svg.append("rect")
.attr("class", "frame")
.attr("width", width)
.attr("height", height);
d3.json("../data/world-countries.json", function(error, collection) {
feature.datum(collection).attr("d", path);
});
function move() {
projection.translate(d3.event.translate).scale(d3.event.scale);
feature.attr("d", path);
}
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment