Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options are not changeable. #2

Open
PlusOne opened this issue Oct 11, 2019 · 2 comments
Open

Options are not changeable. #2

PlusOne opened this issue Oct 11, 2019 · 2 comments

Comments

@PlusOne
Copy link

PlusOne commented Oct 11, 2019

options: street_number, street, city

13, MunichRoad, Munich

example:

options: street, street_number, city

MunichRoad, 13, Munich

If you change the order, it doesnt change the order.

@PlusOne PlusOne changed the title Optioons are not changeable. Options are not changeable. Oct 11, 2019
@rikroe
Copy link

rikroe commented Oct 12, 2019

This a a "common" problem with Google's location APIs (see here).

I found a solution (and have some working code available) that requires a second API call to Google's Places API:

  1. Call https://maps.googleapis.com/maps/api/geocode/json?latlng=LAT,LON and extract the first results.placeid
  2. Now call https://maps.googleapis.com/maps/api/place/details/json?key=API_KEY&placeid=PLACEID and extract results.adr_address. This call does not work without API key.
  3. As this is pseudo-html code, one now needs to extract the data from XML.

Unfortunately, except for some adr_address and some other data, the original geocoding API contains the same info (especially all the address_component data) but there does not seem to be a mapping description of country-specific address formats...

@gregoryduckworth would you accept a PR with this code added? I could imagine controlling it with an additional configuration option (i.e. use_formatted_address which default to False).

On a sidenote: the house number could of course be wrong, depending on the accuracy of your location data :)

EDIT: Wow. I kinda feel I overkilled - though about it again. We of course could use the input order of the user as well... Or if we feel like, provide a Jinja template (the engine is there anyhow)... This way the second API call wouldn't be needed.

@gregoryduckworth
Copy link
Owner

Yeah, happy to accept a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants