Skip to content

shadcn.io is an independent project built on shadcn/ui

3D Buildings Map Block for Svelte

Chicago's Loop on a tilted live map with every building raised to its height, a slider that fades everything lower, and five viewpoints to turn the camera to.

On this page5 sections
UI library: Ark UI

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Read a skyline by height, with this 3D buildings map for Svelte with Ark UI. Storeyline, a city massing tool, raises every building in Chicago's Loop on a tilted live Map that follows your theme, light or dark: the basemap's own vector tiles carry each building's height from OpenStreetMap, and a custom fill-extrusion layer, added through useMap, stands it up. A Slider sets a height: the buildings that reach it stay solid, shaded in four steps of the theme's foreground from under 100 m to 300 m and up, and everything lower fades to a pale ghost, so the towers over 200 m stand out of the city at once. The map runs edge to edge, and the band under it holds the slider with its legend and a Toggle Group of five viewpoints (from the lake, the river, the South Loop and the West Loop, and a plan straight down); choosing one turns and tilts the camera to it, the eye button under the compass flies back to it after you have moved the map, and the compass turns the map to north and flat. Built from Map, Slider, Toggle Group and Guides. For real estate, urban planning, architecture and city guides.

FAQ

Where do the heights come from?

From the basemap itself: CARTO's vector tiles over OpenStreetMap have a buildings layer with each building's height in metres, as mappers recorded it. Nothing else is fetched. A building with no height recorded lies flat on the ground, so a block of low buildings can look emptier than it is.

How does the height slider work?

The buildings are drawn in two layers over the same tiles: one holds the buildings under the height you set, as a pale ghost at less than half opacity, the other the buildings from that height up, shaded by height. Moving the slider only changes the two layers' filters, so it stays smooth while you drag.

How do the colours follow the theme?

MapLibre's layers can't read CSS variables, so each shade is a mix of the theme's foreground into its background, resolved to a colour through the map's resolveColor before the layers go on. A theme swap loads the other basemap, which drops custom layers; the block adds them again, in the new colours, as soon as the map is ready.

Can I use it without a mouse?

Yes. The height is a slider that moves in steps of 10 m with the arrow keys, and the viewpoints are a toggle group whose buttons turn the camera with Enter or Space. The zoom buttons, the compass and the button back to the viewpoint work from the keyboard, and the map takes the arrow keys and plus and minus once focused. A polite message gives the height and the viewpoint once a change settles.

How does it look on a phone?

The map comes first, a zoom level further out so the Loop fits, then the slider with its legend and the viewpoints, which wrap onto a second line. Scrolling over the map scrolls the page; hold Ctrl or ⌘ to zoom it, or use two fingers. On wider screens the slider and the viewpoints sit side by side under the map.

Can I use another city?

Yes: change the viewpoints in VIEW_LINES (a centre, a bearing, a tilt and a zoom each) and the map's maxBounds. Building heights are best where OpenStreetMap mappers have recorded them, as in most large city centres.