Skip to main content
100%

Tile by Bounding Box

✓ Published0🌍 Public
CCurran Kelleher
Last edited Mar 9, 2019
Created on Mar 9, 2019

This example demonstrates how to automatically position map tiles from OpenStreetMap to fit a specified geographic bounding box, using a Mercator projection. The code calculates the necessary scale and translation to center the bounding box, adjusts the projection with `d3.geoMercator()`, and generates the appropriate tile URLs via `d3.tile()`. A vector outline of US states, rendered with `d3.geoPath()`, is overlaid on the raster tiles to show the projection's alignment.

AI-generated description

A demo of d3-tile when projecting to fit a bounding box.

Tiles copyright OpenStreetMap contributors.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/eb0c48375fcdcdc00c54a92724733d0d'>Tile by Bounding Box</a>

gpl-3.0 Licensed

Similar vizzes