d3.js map with markers
This example demonstrates two techniques for placing geographic markers on a d3.js map, centered on Berlin using a Mercator projection. The map renders world land masses and country boundaries from TopoJSON, overlaid with a graticule. Transit stop locations from a GeoJSON file are displayed in two ways: first, by leveraging d3.geo.path() to draw the GeoJSON directly as green path elements; second, by projecting coordinates to screen positions and appending small yellow SVG circles. The visualization compares these two marker approaches, showing that d3.geo.path() handles all projection work automatically, while the manual method uses projection(d.geometry.coordinates) to position custom SVG shapes. The example uses d3.v3 with SVG rendering and a Mercator projection centered on Berlin.
AI-generated descriptionEasy example on how to put marker on a d3.js map.
You got 2 options:
- using d3.geo.path() which does all the work for you
- using svg circles and translating them via projection(d.geometry.coordinates)