diff --git a/README.md b/README.md index c128d30..87df07f 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,18 @@ Option: Show Points of Interest | Boolean | `false` | Set to true to return poin > For more information regarding the AddressFinder options see the options section of the AddressFinder Widget [documentation](https://addressfinder.nz/docs/widget_docs). +### New Zealand vs Australian addresses + +By default, the AddressFinder Widget control will return New Zealand addresses, even if the `Country Code` input property is not set. To return Australian addresses the `Country Code` property must be set to `AU`. + +There are a few subtle differences in the properties that are populated between New Zealand and Australian addresses. This is due to the AddressFinder API returning different properties in the search responses for each country. As a result, the following output properties are only populated by their respective countries. + +Property | Country +--- | --- +City | New Zealand +Suburb | New Zealand +Locality | Australia +State/Territory | Australia ## Roadmap diff --git a/src/AddressFinderWidget/ControlManifest.Input.xml b/src/AddressFinderWidget/ControlManifest.Input.xml index e6a1a9f..97accc3 100644 --- a/src/AddressFinderWidget/ControlManifest.Input.xml +++ b/src/AddressFinderWidget/ControlManifest.Input.xml @@ -1,13 +1,18 @@ - + + + - - + + + + - + + diff --git a/src/AddressFinderWidget/index.ts b/src/AddressFinderWidget/index.ts index 1e5f50f..8da8497 100644 --- a/src/AddressFinderWidget/index.ts +++ b/src/AddressFinderWidget/index.ts @@ -11,13 +11,21 @@ export class AddressFinderWidget implements ComponentFramework.StandardControl; + // AddressFinder params + private _country_code: string | null; + private _options: object; + // AddressFinder fields private _address_line_1: string; private _address_line_2: string; - private _city: string; - private _suburb: string; + private _suburb: string; // NZ only + private _city: string; // NZ only + private _locality_name: string; // AU only + private _state_territory: string; // AU only private _postcode: string; private _country: string; + private _latitude: string; + private _longitude: string; // AddressFinder widget private AddressFinder: any; @@ -49,6 +57,15 @@ export class AddressFinderWidget implements ComponentFramework.StandardControl { - - var selected = new this.AddressFinder.NZSelectedAddress(fullAddress, metaData); - - this._address_line_1 = selected.address_line_1(); - this._address_line_2 = selected.address_line_2(); - this._suburb = selected.suburb(); - this._city = selected.city(); - this._postcode = selected.postcode(); - this._country = "New Zealand"; - this._notifyOutputChanged(); - }); + switch (this._country_code) { + case "AU": + this.Widget.on("result:select", (fullAddress: any, metaData: any) => { + this._address_line_1 = metaData.address_line_1; + this._address_line_2 = metaData.address_line_2; + this._locality_name = metaData.locality_name; + this._state_territory = metaData.state_territory; + this._postcode = metaData.postcode; + this._country = "Australia"; + this._latitude = metaData.latitude; + this._longitude = metaData.longitude; + this._notifyOutputChanged(); + }); + break; + default: // NZ + this.Widget.on("result:select", (fullAddress: any, metaData: any) => { + var selected = new this.AddressFinder.NZSelectedAddress(fullAddress, metaData); + this._address_line_1 = selected.address_line_1(); + this._address_line_2 = selected.address_line_2(); + this._suburb = selected.suburb(); + this._city = selected.city(); + this._postcode = selected.postcode(); + this._country = "New Zealand"; + this._latitude = selected.metaData.y; + this._longitude = selected.metaData.x; + this._notifyOutputChanged(); + }); + break; + } }; /** diff --git a/src/solution/Other/Solution.xml b/src/solution/Other/Solution.xml index 817677c..7a3c3da 100644 --- a/src/solution/Other/Solution.xml +++ b/src/solution/Other/Solution.xml @@ -7,8 +7,10 @@ - - 1.1.16 + + + + 1.2.21 2