Skip to Content
dk-address

How it works

How the field guides people from a street name to a full address.

This page explains what the field does with each pick, so you can design hints and form handling around it. KDS answers at different levels depending on how specific the text is: road names, a road in one postal area, a building, or a full address with floor and door. When only one match is left, it skips to the next level. The field turns these levels into steps.

From street to address

Picking a suggestion either refines the text or completes the field:

  • Refine: the text is rewritten, the caret moves into a gap, the list stays open, and a new search runs at once
  • Complete: the text becomes the address, the list closes, and the full details are loaded
PickedSearching addresses (default)Searching buildings (kind: "accessAddress")
A road name (streetName)Lærkesti |same
A road name and number (streetNameNumber)Christian 10 Gade 8|same
A road in a postal area (street)Vesterbrogade |, 1620 København Vsame
A building (accessAddress)Vesterbrogade 28, |, 1620 København Vcompletes
A full address (address)completes(not returned)

| is where the caret goes. The gaps use KDS's own punctuation, so typing into them produces the address as KDS writes it: Vesterbrogade 28, st. 1, 1620 København V.

Filling a gap

While someone types into a gap, state.slot describes it: what it wants (houseNumber or unit) and what's typed so far. Editing outside the gap ends it. Use it for hints, like "Type the house number".

KDS only matches whole house numbers, so Vesterbrogade 2, 1620 finds nothing on the way to 28. After a street is picked, the field loads that street's house numbers once (about 20 KB) and matches them by prefix as you type, after KDS's own results. Turn it off with houseNumberPrefix: false. If the house numbers can't be loaded, the field shows KDS's own matches only.

Floors and doors match by prefix in KDS itself: st finds the ground-floor units and 2. t finds 2. tv and 2. th.

When it's done

A completed pick sets state.selection. With the default fetchDetails: true the full address is loaded first, then onSelect is called with it:

  • id, label, floor and door
  • the building (accessAddress) with its house number, street, postal code, municipality code and position (EPSG:25832)
  • raw, the untouched KDS object

Editing the text afterwards clears the selection, so your form never keeps an address that no longer matches the text.

Searching buildings instead

With kind: "accessAddress" the field stops at buildings (KDS's husnummer or adgangsadresse) instead of going down to floor and door. Use it when you need an entrance, not a dwelling, for example for deliveries to a whole building.