Geolocation Oddity

By: Rob LeVine | Asked: 11/14/2022
ForumsCategory: General questionsGeolocation Oddity
Rob LeVineRob LeVine asked 2 years ago
Apparently, there's an oddity with Google's geolocation that addresses in cities such as New York and Tokyo don't have city name data (i.e., the "locality" value is blank though the sublocality field is filled in).  Google knows about it and set its status to "Won't fix (Intended behavior)" so we're stuck with it.  I get the feeling that I'm going to end up writing jQuery code to run the API query and parse the JSON data to grab the "sublocality", however, before I do so I'm wondering if anyone else has encountered and conquered this problem.  I think I will report it to Formidable to see if they can maybe update the Geolocation AddOn to handle this situation. If you have a Google Maps Server API Key you can add it to the end of the following URLs to see the following example of an address in NYC https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key= vs. and address in Boston, which gives the city as its locality https://maps.googleapis.com/maps/api/geocode/json?latlng=42.3596927,-71.0581457&key=
Rob LeVineRob LeVine replied 2 years ago

I contacted Formidable Support about updating the Geolocation add-on to handle this case by offering an option to substitute sublocality for locality when locality is blank.

1 Answers
Rob LeVineRob LeVine answered 2 years ago

I made this tutorial to solve (or at least work around) the issue https://connect.formidableforms.com/question/category/code-snippets/solving-geolocation-issue-with-empty-city-field/

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right