Skip to content

Commit 3a1f531

Browse files
authored
gpaa-plus-code.js: Migrated
1 parent a1c7410 commit 3a1f531

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

experimental/gpaa-plus-code.js

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,5 @@
11
/**
2-
* Gravity Perks // GP Address Autocomplete // Display Google Plus Code
3-
*
4-
* Adds a Google Plus Code to the configured text field when an address is autocompleted.
5-
*
6-
* Instructions:
7-
* 1. Install our free Custom JavaScript for Gravity Forms plugin.
8-
* Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
9-
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
10-
* 3. Update the field id variables to match your the address and text fields you would like this to
11-
* apply to.
2+
* We're no longer using the experimental folder for experimental snippets. 🚧
3+
* You can now find the snippet here:
4+
* https://github.com/gravitywiz/snippet-library/blob/master/gp-address-autocomplete/gpaa-plus-code.js
125
*/
13-
14-
// update this with the id of the address field you want this to apply to.
15-
var addressFieldId = 1;
16-
// update this with the id of the text field you would like the plus code displayed in.
17-
var plusCodeFieldId = 3;
18-
19-
window.gform.addFilter('gpaa_autocomplete_options', (autocompleteOptions, gpaa, formId, fieldId) => {
20-
if (formId !== 'GFFORMID' && fieldId !== addressFieldId) {
21-
return autocompleteOptions;
22-
}
23-
24-
autocompleteOptions.fields.push('plus_code');
25-
26-
return autocompleteOptions;
27-
});
28-
29-
window.gform.addAction('gpaa_fields_filled', (place, instance) => {
30-
// "plus_code" includes both "global_code" or "compound_code" as documented here: https://developers.google.com/maps/documentation/javascript/reference/places-service#PlacePlusCode
31-
var plusCode = place?.plus_code?.global_code || 'No Plus Code found';
32-
33-
$('#input_GFFORMID_' + plusCodeFieldId).val(plusCode);
34-
});

0 commit comments

Comments
 (0)