United States Map
Description:
An Albers USA projection of the United States with both individual state and county levels available.
<!DOCTYPE html>
<html>
<head>
<title>United States Map</title>
</head>
<body>
<h1>United States Map</h1>
<div id="map" style="position: relative; width: 100%; max-width: 700px; height: 350px;"></div>
<script src="https://world-map.org/cartography/scripts/d3.js"></script>
<script src="https://world-map.org/cartography/scripts/d3-topojson.js"></script>
<script src="https://world-map.org/cartography/datamaps/world/world.min.js"></script>
<script>
var usa_map = new Datamap({
element: document.getElementById("map"),
scope: 'usa',
fills: {defaultFill: '#859EDE'},
geographyConfig: {
highlightFillColor: 'EDDE45'
}
});
usa_map.labels();
</script>
</body>
</html>
USA Counties Map
A map of all the counties in the United States using the FIPS code from the USDA.
These codes can be found at https://www.nrcs.usda.gov/ for reference.
<!DOCTYPE html>
<html>
<head>
<title>USA Counties Map</title>
</head>
<body>
<h1>USA Counties Map</h1>
<div id="map" style="position: relative; width: 100%; max-width: 700px; height: 350px;"></div>
<div style="clear: both;"></div>
<button class="zoom-button" data-zoom="reset">0</button>
<button class="zoom-button" data-zoom="out">-</button>
<button class="zoom-button" data-zoom="in">+</button>
<div id="zoom-info"></div>
<script src="https://sabalico.dev/jquery.js"></script>
<script src="https://world-map.org/cartography/scripts/d3.js"></script>
<script src="https://world-map.org/cartography/scripts/d3-topojson.js"></script>
<script src="https://world-map.org/cartography/scripts/datamaps-zoom.min.js"></script>
<script src="https://world-map.org/cartography/datamaps/world/world.min.js"></script>
<script>
function Datamap() {
this.$container = $("#map");
this.instance = new Datamaps({
scope: "county",
element: this.$container.get(0),
setProjection: function(element, options) {
var projection, path;
projection = d3.geo.albersUsa()
.scale(element.offsetWidth)
.translate([element.offsetWidth/2,element.offsetHeight/2]);
path = d3.geo.path()
.projection(projection);
return {path: path, projection: projection};
},
geographyConfig: {
dataUrl: "https://world-map.org/cartography/topojson/usa/usa-counties.json",
hideAntarctica: false,
borderWidth: 1,
borderOpacity: 1,
borderColor: '#FDFDFD',
popupTemplate: function(geo, data) {
return ['<div class="hoverinfo"><p style="font-weight:bold">'+geo.properties.NAMELSAD10+'</p></div>'].join('');
},
popupOnHover: true,
highlightOnHover: true,
highlightFillColor: '#FC8D59',
highlightBorderColor: 'rgba(250, 15, 160, 0.2)',
highlightBorderWidth: 2,
highlightBorderOpacity: 1
},
fills: {
bubbleMax: "#8F2C4B",
bubbleMin: "#8F5974",
defaultFill: "#859EDE",
MIN: "#d7eebd",
LOW: "#8fd3bd",
MEDIUM: "#45aec0",
HIGH: "#317bb4",
MAX: "#084182"
},
data: {},
done: this._handleMapReady.bind(this)
});
}
Datamap.prototype._handleMapReady = function(a) {
this.zoom = new Zoom({
$container: this.$container,
datamap: a
});
};
new Datamap();
</script>
</body>
</html>