Leaflet and D3 Map
✓ Published0🌍 Public
Dd3noob
Last edited Nov 30, 2019
Created on Feb 25, 2014
This example combines Leaflet and D3 to render a blue GeoJSON rectangle polygon that pans and zooms with an OpenStreetMap tile layer. It uses D3’s `d3.geo.path` with a custom `projectPoint` function that calls Leaflet’s `latLngToLayerPoint`, while a `viewreset` handler recalculates the SVG overlay’s bounds and transform. The map is centered on Wellington, New Zealand, and the rectangle’s path is drawn as SVG elements within Leaflet’s overlay pane.
AI-generated descriptionThis is a map that uses leaflet.js and d3.js in a way that combines the two so that the d3.js object zooms and pans with the map. It is as used as an example in the book D3 Tips and Tricks.
It is derived from the Mike Bostock tutorial on Leaflet but is simplified somewhat.
mit Licensed