Skip to content

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

Overview Inset Map Block for Vue

A street-level course map of a Copenhagen half marathon with an overview inset of the whole loop; drag the box in the inset to move the detail.

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

Keep the big picture in a corner while you read the streets, with this overview inset map for Vue with Ark UI. Kerbmile, a road-race organiser, draws the Harbour Half, a 21.1 km loop through Copenhagen from Rådhuspladsen, on a live street-level Map that follows your theme, light or dark, with a marker at every kilometre and a droplet at each of the four water stations. A second, small map in the corner holds the whole loop and a box that is the street map's view: it moves and resizes as you pan and zoom. Press anywhere on the overview to bring the street map there, or take hold of the box and drag it round the course; the street map follows the pointer at its own zoom. The card lists the checkpoints, each a button that flies the street map to its kilometre, and reads the stretch of course in view ("km 4.2 to 6.8 in view") from the same box. Built from Map and Guides. For race and event maps, trails, tours, survey sites and any map people read up close but need to place in a larger area.

FAQ

How does the box follow the street map?

A small ViewWatcher inside the street map reads its corners, middle and zoom on every frame it moves and when it's resized. The overview draws those corners as a GeoJSON polygon with MapGeoJSON, so the box moves and grows or shrinks with every pan and zoom, from the buttons, the keyboard or the pointer.

What happens when I drag on the overview?

The overview has its own panning turned off (interactive: false), and a helper reads where the pointer presses and moves on it. A press inside the box keeps the spot you took hold of under the pointer; a press outside brings the box's middle there. Each point aims the street map's MapCamera with no flight, at its current zoom, so the street map follows the pointer.

Can I use it without a mouse?

Yes. Each checkpoint in the card is a button that flies the street map to its kilometre; the street map takes the arrow keys and plus and minus once focused, and the zoom buttons work from the keyboard. The overview is a picture of where you are: the box moves with every move you make, and a polite message says which kilometres are in view once the map settles.

Where does the course come from, and what stays local?

The loop was routed once along Copenhagen's real streets with OpenStreetMap's foot routing (OSRM), simplified and typed into the file. The kilometre markers sit at their share of the line (MapRouteMarker at), and the stretch in view is worked out from the same points. Kerbmile, the race, its date and its stations are invented. Nothing is fetched or saved but the map tiles.

How does it look on a phone?

The street map comes first with the overview in its top corner, smaller; a finger drags the box without scrolling the page. The card docks under the map with the checkpoints and the stretch in view. One finger scrolls the page over the street map and two fingers pan it.