AdvancedCustomFields / AdvancedCustomFields/acf
Google Map / Location Field - Missing data in UK (town)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
I live in the UK and in Google Maps Geocoding API if I type a location in it'll sometimes have the city / town under "postal_town" rather than "city" in the result JSON.
Because ACF doesn't map and save that piece of data I can't display towns on the front-end. It saves only postcode, address, city, place id etc at the minute but doesn't have postal_town for these addresses.
The workaround is for me to do a double API call (on saving the field re-run the call and save the town to another field, which is very bad practice and going to cost a lot) or scrap the location field all together because I can't find a way to hook in.
Is there any filter that I can add it with or is it possible to add one so we can map other data from the API results?
Example:
"BB8 8JU" returns this from ACF location field:
{
address: "BB8 8JU"
country: "United Kingdom"
country_short: "GB"
lat: 53.8455506
lng: -2.1899245
place_id: "ChIJHZKvtn-Re0gRjn92nwMlTNQ"
post_code: "BB8 8JU"
state: "England"
zoom: 14
}
You'd expect that you could retrieve the town from there at least since it's returned in the geocoding API:
"results" : [
{
"address_components" : [
{
"long_name" : "BB8 8JU",
"short_name" : "BB8 8JU",
"types" : [ "postal_code" ]
},
{
"long_name" : "Colne",
"short_name" : "Colne",
"types" : [ "postal_town" ]
},
{
"long_name" : "Lancashire",
"short_name" : "Lancashire",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "England",
"short_name" : "England",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United Kingdom",
"short_name" : "GB",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Colne BB8 8JU, UK",
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the ACF location field's Google Geocoding API response mapping and compare the saved fields with the returned postal_town component. Done means UK postal towns are available from the location field without a second API call, either through supported mapping or a documented filter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100