Skip to main content
100%

D3 GeoJSON in Leaflet

✓ Published0🌍 Public
ZZJONSSON
Last edited May 7, 2013
Created on May 7, 2013

This example shows a map of New York City where roads and water areas are rendered as vector tiles, with roads drawn as black strokes and water filled in blue. It combines Leaflet’s tile layer mechanism with D3’s `d3.geo.path` to project and draw GeoJSON features fetched from OpenStreetMap’s vector tile service. A custom `L.TileLayer.d3_geoJSON` class extends Leaflet, appends an SVG group to the map container, and uses `d3.json` to load each tile’s data, while aborting requests and removing nodes on tile unload to manage performance.

AI-generated description

UPDATE: The Vector Tiles are not being served at this time by Openstreetmap. Try later or a different provider (example) Services seem to have resumed

A simple test of extending the L.TileLayer to fetch geoJSON tiles from openstreetmap and render them with d3. This is probably not the most efficient way to do this, as we accept empty image tags (from the standard TileLayer) and use them as containers for the data/requests.

Similar vizzes