Configuration

At instantiation you supply a configuration-object.


// A typical config-object 
var config = {
    apiKey: '803u19hed3929901' /*my-ah-key*/,
    limitToOfficial: true

Vital configuration

apiKey

Your API-key. Mandatory.

country

Country code for the lookup (NO, SE or FI). Default is Norwegian addresses (NO).

limitToOfficial

If you want to limit the results to official Norwegian addresses (will eliminate duplicates). Default: false.

lookOnlyForAddress

If you don’t want to prompt the user to supply details like floor and flat. If the pure address is enough. Default: false.

useGeoLocation

If you want the location of the user to affect the results. When activated, we use a service that deduces the city from the users IP-address, and the first street shown in the result will use the current city as a filter. This means that this feature works best when the user have typed most of the streetname, but it will only work in places where the user’s city (in Norway: “by”) matches the address’ city (in Norway: “poststed”). Default: false. NB: If you plan to use this feature, make sure you send us an email with the domains (no need to supply each subdomain), so we can add them to the whitelist of our supplier.

Other configuration

serviceUrl (DEPRICATED)

If needed to override the server-URL (i.e. if needed to target a test-environment).
DEPRICATED: use baseUrl instead.

baseUrl (from 1.1.0)

If needed to override the server-URL (i.e. if needed to target a test-environment).
Default: https://ws.di.no. If you want to use Address Helper’s dev or staging backends, use https://dev-ws.di.no or https://staging-ws.di.no.

labels

Override the texts in the default skin and miscellaneous wordings. Supply an object with the keys you want to override. For texts in the default skin: street, streetNumber, floor, household, zip and city.
For texts in the flat-selector: flat (you can use placeholders to show floor type, floor and flatno) and flatUnknown.
For texts in the street-selector: loadingMore and loadingDone.
For the search-hint that appears when you scroll in the street-selector: streetHint. Default is '<strong>Tips:</strong> Skriv <em>,</em> og <em>POSTSTED</em>'
Placeholders in flat:

  • %t (floor type: H, U, L or K)
  • %f (floorNo - prepadded with 0 like this: 2 -> 02 but 11 -> 11)
  • %a (flatNo - prepadded with 0 like this: 2 -> 02 but 11 -> 11)
  • %x (flatalias)
  • # (flatNo - without prepadding)

houseTypes

Background: If there are multiple addresses with the same street number / entrance, the house type will be shown to the user to help with the right choice. House types: Detached house (E), Terraced house (R), Apartment building (B), Shop/business (F), Other (A) and Cabin (H). To override the house type, supply an object with the keys you want to override.
Available keys (within the houseTypes-object): E, R, B, F, A and H.

floorTypes

Possible to override the texts that are shown in the list of floors. The types are Main-floor (H), Sub-floor (U), Loft (L) and Basement (K). Use the character # as a placeholder for the floorNumber. (introduced in 1.0.8)
Available keys (within the floorTypes-object): H, U, L and K.

allowFreeform

If you want the user to enter any kind of address, whether it is valid or not, you can enable this mode. The user is then not forced to pick a valid street name. The street names or street numbers are only hints and suggestions. This mode will easily lead to reduced address quality, since it is less strict validation. NB: If you also need the user to be able to enter floor and flat, the default skin will not support this out of the box. Standard: false. [Experimental]

disableDefaultSkinEvents

If you are using the default skin (letting us create the DOM for you), but don’t want the default event handler, you can disable it with this option. It’s then up to you to wire it up. Standard: false

disableHouseholdHelpPanel

If you are using the default skin and DON’T want to show the “Household Helper”-button, enable this flag. Can be nice if performing A/B-testing to test the effect of this explanation/help. Standard: false

distributionSupport

If you are in a distribution-context (with products that are handled through DI), use this setting to enable automatic coverage-check on completion of an address. Must set distributionSupport.product (shortname) and distributionSupport.customerSystem (shortname). Also possible to set distributionSupport.distributionDate (YYYY-MM-DD). If date is not given, the first possible date from the product’s calendar will be used. This config is the easiest way to check coverage and you only need to listen to the event productSupportEvent. For a more manual approach, see the methods getProductSupport() and getDistributions().
Standard: Not configured

showClear

If you use the default skin, you have the option to add clear-icons for each field. This is especially useful if you prepopulate Address Helper and want the user to easy understand how to change his/her address. When reseting each field, it will also clear the more detailed choices (clearing streetNumber will clear floor/flat, clearing street will clear everything etc)

maxResultsDisplayed

If you want to increase the number of results given by a lookup. Can in rare cases be relevant to increase this, but default should be good enough. Standard: 50

Example


// Example of overriding texts and enabling geo location
var config = {
  apiKey: '803u19hed3929901' /*my-ah-key*/, 
  limitToOfficial: true,
  useGeoLocation: true,
  houseTypes: { F: "shop", B: "house", E: "house", R: "house" },
  floorTypes: { K: "Basement #" },
  labels: { zip: "Zip", flatUnknown: "I don't know" } 
};