Public
Edited
Apr 5, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// projection = d3.geoMercator() // this one is commented out because the dropdown above is setting it instead.
Insert cell
// projection.center([-78,38]) // roughly Charlottesville, VA
Insert cell
// projection.scale(1000)
Insert cell
// see the mapLayers cell below, and comment, uncomment, and modify values there.
Insert cell
Insert cell
map = d3.select(mapContainer)
Insert cell
import {getMapData, drawMapLayer} with {map, projection} from "@emfielduva/dvlib_maps"
Insert cell
world = getMapData("world110m")
Insert cell
mapLayers = {
//projection.scale(1000);
//projection.center([-78,38]);
//projection.rotate([78,-38]);
let mapLayers = [];
mapLayers["countries"] = drawMapLayer(map,"countries",world.features,world.idField);

mapLayers["graticules"] = map.select("#graticule").selectAll("path")
.data(graticule.coordinates)
.join("path")
.attr("d", pathGenerator(graticule));
return mapLayers;
}
Insert cell
<style>
#countries path {fill: #ddd; stroke: #ccc}
#graticule path {fill: none; stroke: #eee; stroke-width: 0.5;}
</style>
Insert cell
Insert cell
graticule = d3.geoGraticule10()
Insert cell
pathGenerator = d3.geoPath().projection(projection);
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more