The VisDock toolkit has been integrated into this Raster & Vector Zoom example built with D3.js (found here) by Mike Bostock. Selection tools do not provide much functionality in this example. Annotations, Pan & Zoom tools and VisDock lenses can be used for exploration of the map. Especially, the BirdEye provides the overview of the map from a higher perspective. For more information about VisDock, cick on the link.
xxxxxxxxxx
<meta charset="utf-8">
<style>
body {
margin: 0;
}
path {
fill: none;
stroke: red;
stroke-linejoin: round;
stroke-width: 1.5px;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://d3js.org/d3.geo.tile.v0.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<link href="https://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.css" rel="stylesheet" type="text/css"/>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/visdock.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/2d.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/intersectionutilities.js"></script>
<script src="https://rawgithub.com/visdockhub/newvisdock/master/master/visdock.utils.js"></script>
<script>
var width = 1200;
height = 700;
VisDock.init("body", {width: 1200, height: 700});
var viewport = VisDock.getViewport();
var tile = d3.geo.tile()
.size([width, height]);
var projection = d3.geo.mercator()
.scale((1 << 12) / 2 / Math.PI)
.translate([width / 2, height / 2]);
var center = projection([-100, 40]);
var path = d3.geo.path()
.projection(projection);
var zoom = d3.behavior.zoom()
.scale(projection.scale() * 2 * Math.PI)
.scaleExtent([1 << 11, 1 << 14])
.translate([width - center[0], height - center[1]])
.on("zoom", zoomed);
var svg = viewport;
var raster = svg.append("g");
var vector = svg.append("path");
d3.csv("us-state-capitals.csv", type, function(error, capitals) {
svg.call(zoom);
vector.datum({type: "FeatureCollection", features: capitals});
zoomed();
});
function type(d) {
return {
type: "Feature",
properties: {
name: d.description,
state: d.name
},
geometry: {
type: "Point",
coordinates: [+d.longitude, +d.latitude]
}
};
}
function zoomed() {
var tiles = tile
.scale(zoom.scale())
.translate(zoom.translate())
();
projection
.scale(zoom.scale() / 2 / Math.PI)
.translate(zoom.translate());
vector
.attr("d", path);
var image = raster
.attr("transform", "scale(" + tiles.scale + ")translate(" + tiles.translate + ")")
.selectAll("image")
.data(tiles, function(d) { return d; });
image.exit()
.remove();
image.enter().append("image")
.attr("xlink:href", function(d) { return "https://" + ["a", "b", "c", "d"][Math.random() * 4 | 0] + ".tiles.mapbox.com/v3/examples.map-vyofok3q/" + d[2] + "/" + d[0] + "/" + d[1] + ".png"; })
.attr("width", 1)
.attr("height", 1)
.attr("x", function(d) { return d[0]; })
.attr("y", function(d) { return d[1]; });
}
BirdView.init(viewport, 1200, 700)
d3.select(self.frameElement).style("width", "1200px");
d3.select(self.frameElement).style("height", "700px");
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
Modified http://d3js.org/d3.geo.tile.v0.min.js to a secure url
Modified http://d3js.org/topojson.v1.min.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/2D.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/IntersectionUtilities.js to a secure url
Modified http://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.utils.js to a secure url
https://d3js.org/d3.v3.min.js
https://d3js.org/d3.geo.tile.v0.min.js
https://d3js.org/topojson.v1.min.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/2D.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/IntersectionUtilities.js
https://rawgithub.com/VisDockHub/NewVisDock/master/master/visdock.utils.js