Skip to content

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

Emergency Services Map Block for React

Six open calls on a live map of Bristol; pick one to draw the road route from its nearest hospital, fire station and police station, with minutes.

On this page5 sections

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

See who reaches a call first, with this emergency services map for React with Base UI. Sirenwick, a county dispatch planner, puts three hospitals, three fire stations and three police stations in real Bristol neighbourhoods on a live Map that follows your theme, light or dark, with six open calls at real places such as Temple Meads and Harbourside. The calls are a list in a card that floats over the map on wide screens and docks under it on smaller ones; choosing one, there or on its marker, draws the road route from the nearest station of each kind (solid for a hospital, dashed for fire, dotted for police), labels each station with its minutes, fades the stations that don't respond and flies the camera to frame them all. Nearest means the shortest drive: the routes and times were asked once of OpenStreetMap's routing at normal road speeds and baked into the block, never fetched. The card lists the three with their minutes and kilometres and marks the one there first with a Badge. Built from Map, Badge and Guides. For dispatch tools, public-safety dashboards, insurers and facilities planners.

FAQ

How is the nearest station chosen?

By drive time, not by a straight line. For each call and each kind of station, the station with the fewest seconds by road wins; those seconds, the metres and the route itself sit in RESPONSE_LINES, one line per call and service. That is why Harbourside's nearest hospital is in Bedminster, across the river, even though the route is the longest of the three.

Where do the routes and times come from, and what stays local?

They were asked once, while the block was written, of the public OSRM demo over OpenStreetMap data, then simplified to a few dozen points and typed into the file. Nothing is fetched at runtime but the map tiles, and nothing is dispatched or sent. The neighbourhoods and calls' places are real; Sirenwick, the station names and the calls are invented sample data, not advice. In your app, rank stations with your routing service and live unit availability.

Why do the times look slow for an emergency?

They are normal road speeds: an ambulance under lights goes faster, and the caption says so. The block compares stations with one another, so the order matters more than the minutes; swap in your service's own speed model if you have one.

Can I use it without a mouse?

Yes. Every call in the card is a button with a pressed state, and the zoom buttons work from the keyboard; the map itself takes the arrow keys and plus and minus once focused. The markers are a pointer shortcut to the same choice. A polite message names the station there first and the others' minutes once the choice settles.

How does the map frame each call?

The block keeps one aim: the call and its three routes, corner to corner. MapCamera frames it at the start and flies to each new one, at once when reduced motion is on. From the lg breakpoint the card floats over the map's start, so the frame keeps a wide margin on that side; pan and zoom freely in between choices.

How does it look on a phone?

The map comes first, then the caption, then the card docks under it: on a phone as one list, the six calls and then the three nearest stations with their minutes; on a tablet as two columns side by side. The page scrolls over the map; two fingers pan it.