Skip to main content

Bias By Postcode Outward

Static Postcode Outward

Display address results that closely matches the chosen postcode outward value.

It will still display unmatched addresses but they will be ranked lower.

The queryOptions object allows customizing the search query. In this example, the bias_postcode_outward property is set to "NW1" to bias the search results towards the NW1 postcode outward code.

 
AddressFinder.setup({
apiKey: "ak_test",
queryOptions: {
bias_postcode_outward: "NW1"
},
outputFields: {
organisation_name: "#organisation"
line_1: "#first_line",
line_2: "#second_line",
line_3: "#third_line",
post_town: "#post_town",
postcode: "#postcode",
}
});

Live Demo (Static Postcode Outward)

Loading...

Dynamically Updating Bias

The example below includes an event listener, which allows users to dynamically change the bias. When the value of the input field changes, setQueryOptions function is used to apply the new bias.

 
const c = AddressFinder.setup({
apiKey: "iddqd",
queryOptions: {
bias_postcode_outward: "sw1a"
},
outputFields: {
line_1: "#line_1",
line_2: "#line_2",
line_3: "#line_3",
post_town: "#post_town",
postcode: "#postcode"
}
});
const bias = document.getElementById("bias_postcode");
bias.addEventListener("change", (e) => {
c.setQueryOptions({
bias_postcode_outward: e.target.value
});
});

Live Demo (Dynamic Postcode Outward)

Loading...