Skip to content

Instantly share code, notes, and snippets.

@thomaslorentsen
Last active February 24, 2020 17:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomaslorentsen/b362857003b8c15e13015193c5940145 to your computer and use it in GitHub Desktop.
Save thomaslorentsen/b362857003b8c15e13015193c5940145 to your computer and use it in GitHub Desktop.
Custom integration of post code anywhere
pca.on("load", function (type, id, control) {
control.listen("populate", function (address) {
console.log('here');
});
});
// Replace key with pca key
// Refer to documentation http://www.pcapredict.com/capture-plus/reference/2.20/pca.Address.html#Options
var options = {key: 'XXXX-XXXX-XXXX-XXXX', filteringMode: 'Address'};
if (typeof pcakey !== 'undefined') options.key = pcakey;
// For field bindings refer to documentation http://www.pcapredict.com/capture-plus/reference/2.20/pca.Address.html#Binding
// Field modes refer to documentation http://www.pcapredict.com/capture-plus/reference/2.20/pca.html#fieldMode
var fields = [
{element:'postcode', field: "{PostalCode}", mode: 3},
{element:"buildingNum", field: "{BuildingNumber}", mode: 2},
{element:"line1", field: "{Street}", mode: 2},
{element:"line2", field: "{Line2}", mode: 2},
];
pca.ready(function() {
// Create a new address field
control = new pca.Address(fields, options);
// Listen to events
control.listen('populate', function() {
// This function get called when an address has been selected
console.log('Populated Event');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment