Ga naar hoofdinhoud

CnAddressSearch

An address field over the PDOK Locatieserver: BAG addresses, streets, places and postcodes. It suggests as the reader types, runs a free-text search when nothing is suggested, and on a pick looks up the full document and emits it with its coordinates. It is built on CnSearchSelect.

Browsers never call api.pdok.nl directly. Requests go to a PDOK proxy that serves suggest, free and lookup/{id}. By default that is the /api/pdok route of the first installed app in appCandidates (integriq, then openconnector, its former id). Use endpoint to name another base URL. When the proxy answers 404 (not installed) or 503 (PDOK down), the field says address search is not available and stays usable, so a form around it can still be saved.

Usage​

<CnAddressSearch
v-model="form.address"
label-outside
@select="onAddress" />
onAddress(chosen) {
// chosen: { result, coordinates: { lat, lng } | null, address } or null when cleared
}

Props​

PropTypeDefaultDescription
modelValueStringnullThe chosen address text
endpointString''Base URL of the PDOK proxy; empty resolves it from appCandidates
appCandidatesArray['integriq', 'openconnector']App ids that serve /api/pdok, newest first; the first installed one wins
inputLabelString''The field's label; defaults to "Search an address"
labelOutsideBooleanfalseDraw the label above the field
placeholderString''Placeholder; defaults to "Street, postcode or place"
clearableBooleantrueOffer a clear button
disabledBooleanfalseDisable the field
minLengthNumber3The fewest characters a search needs
rowsNumber10The most results a free-text search returns

Events​

EventPayloadDescription
update:modelValueaddress text or nullThe chosen address
select{ result, coordinates, address } or nullThe looked-up document, { lat, lng } or null, and the display text

Helpers​

addressCoordinates(doc) and addressText(doc) are named exports of the component file. They read { lat, lng } and the display text from a normalised document (location.coordinates, displayName) or a raw Locatieserver one (centroide_ll, weergavenaam).