Using d3-carto-map to create a map which cannot be zoomed or panned.
Created
December 16, 2014 20:15
-
-
Save lmullen/5b2481ecceaa7372d7b1 to your computer and use it in GitHub Desktop.
Unzoomable d3-carto-map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>D3-carto-map with Albers USA projection</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" type="text/css" href="https://rawgit.com/emeeks/d3-carto-map/master/d3map.css"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
</head> | |
<body onload="makeMap();"> | |
<div id="viz"></div> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="https://rawgit.com/emeeks/d3-carto-map/master/d3.carto.map.js"></script> | |
<script src="visualization.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#viz { | |
width: 100%; | |
height: 100%; | |
} | |
.city { | |
fill: none; | |
stroke: red; | |
stroke-width: 1px; | |
} | |
.land { | |
fill: lightgray; | |
stroke: black; | |
stroke-width: 1px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeMap() { | |
var map = d3.carto.map(); | |
d3.select("#viz").call(map); | |
usLayer = d3.carto.layer.topojson(); | |
usLayer | |
.path("us.topojson") | |
.label("USA") | |
.renderMode("svg") | |
.specificFeature("counties") | |
.clickableFeatures(true) | |
.cssClass("land"); | |
map | |
.addCartoLayer(usLayer); | |
map | |
.setScale(3) | |
.centerOn([-98.5795,39.8282], "latlong") | |
.zoomable(false); | |
d3.selectAll(".d3MapControlsBox").style("display", "none"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment