Address Autocomplete
Features
Google Place Autocomplete
Status
Release Available | Status | Framework Name |
---|---|---|
2.8 | Current | TBC |
General
Get Google API key
Add the URL to the whitelist of Google API key
Add the following line to the VF page
Code JSON
Copy
<script src="https://maps.googleapis.com/maps/api/js?key=your+key&libraries=places"></script>
addressComponentRestrictions is optional.
addressComponent types can be found athttps://developers.google.com/maps/documentation/geocoding/intro#Types
Code JSON
Copy
{"fields": [{
"id": "31ad", "fieldName": "address",
"fieldUi": {
"fieldType": "addressAutocomplete",
"addressComponentMapping": [{
"addressComponent": "street_number", "fieldName": "address"
}, {
"addressComponent": "route", "fieldName": "address"
}, {
"addressComponent": "locality", "fieldName": "city"
}, {
"addressComponent": "administrative_area_level_1", "fieldName": "state"
}, {
"addressComponent": "country", "fieldName": "country"
}],
"addressComponentRestrictions": {"country": ["in"]}
}
},
{"id": "2bd5", "fieldName": "city", "fieldUi": { "fieldType": "string", "label": "City" }},
{"id": "daeb", "fieldName": "state", "fieldUi": { "fieldType": "string", "label": "State" }},
{"id": "27a0", "fieldName": "country", "fieldUi": { "fieldType": "string", "label": "Country"}}
]...
"formatted_address" is a special address component, including the complete suggested address
Code JSON
Copy
"fieldUi": {
"fieldType": "addressAutocomplete",
"addressComponentMapping": [
{ "addressComponent": "formatted_address", "fieldName": "Home_Address" },
{ "addressComponent": "street_number", "fieldName": "Street_Number" },
{ "addressComponent": "route", "fieldName": "Street_Name" },
{ "addressComponent": "locality", "fieldName": "City" },
{ "addressComponent": "administrative_area_level_1", "fieldName": "State_Address" },
{ "addressComponent": "postal_code", "fieldName": "Postal_Code" }
],
"addressComponentRestrictions": { "country": [ "aus" ] }
}
Google Address Complete Enhancement
Status
Release Available | Status | Framework Name |
---|---|---|
3.3 | Current | TBC |
General
addressTypes
By default, if nothing is specified, the addressTypes are
["address"]
because address instructs the Place Autocomplete service to return only geocoding results with a precise address.
All the values listed in the above link can be used.
Code JSON
Copy
{
"fieldUi": {
"fieldType": "addressAutocomplete",
"addressComponentMapping": [...],
"addressComponentRestrictions": {...},
"addressTypes": ["geocode"]
}
}