google / libaddressinput

Google’s postal address library, powering Android and Chromium
Apache License 2.0
573 stars 103 forks source link

Mapping of Google "address components" to "address format" #119

Open ChristianAdamski opened 7 years ago

ChristianAdamski commented 7 years ago

Hey,

do you have further data on how to map the single address_components coming from the Google Geocoding API to the address formats?

The pretty simple example question would be which comes first in the address line 1, [Street] [Number] or [Number] [Street], the former i.e. US, the latter in Germany.

I cannot find any useful mapping data for this.

lararennie commented 7 years ago

Their API should also return the address formatted with micro-format markup, no? That will have the street name and number in the right order, and can be easily extracted to the street number field as is from the relevant span if you want to use it to populate the widget.

  1. jan. 2017 2.44 p.m. skrev "Christian Adamski" <notifications@github.com

    :

Hey,

do you have further data on how to map the single address_components coming from the Google Geocoding API to the address formats?

The pretty simple example question would be which comes first in the address line 1, [Street] [Number] or [Number] [Street], the former i.e. US, the latter in Germany.

I cannot find any useful mapping data for this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/googlei18n/libaddressinput/issues/119, or mute the thread https://github.com/notifications/unsubscribe-auth/AIjis96KdueVkC6LW4fMZLNc0otSFBt0ks5rV1HUgaJpZM4Ltf79 .

ChristianAdamski commented 7 years ago

The issue might more complex than that. I'm maintaining the geolocation Drupal module, which allows to interact with the address Drupal module, which in turn is based on this data.

And now people come and tell me that in NYC the locality is not the city, but the neighborhood field, or that in Argentina the adminstrative area must be filled with something else etc.

Google in all these cases gives the correct formatted string, but I cannot find any mapping data from the single components to that formatted string.

ChristianAdamski commented 7 years ago

I will look at your idea.later though, maybe it works out. Thanks so far

ChristianAdamski commented 7 years ago

@lararennie I just checked: no micro-format from Google Geocoding. It's a plain string.

lararennie commented 7 years ago

https://developers.google.com/places/web-service/details shows adr_address with:

<span class=\"street-address\">48 Pirrama Rd, <span class=\"locality\">Pyrmont <span class=\"region\">NSW <span class=\"postal-code\">2009, <span class=\"country-name\">Australia

2017-01-26 16:24 GMT+01:00 Christian Adamski notifications@github.com:

@lararennie https://github.com/lararennie I just checked: no micro-format from Google Geocoding. It's a plain string.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/googlei18n/libaddressinput/issues/119#issuecomment-275416048, or mute the thread https://github.com/notifications/unsubscribe-auth/AIjisxJjNqsM3_8ZXbh2f_SEuMuztnI9ks5rWLqsgaJpZM4Ltf79 .

ChristianAdamski commented 7 years ago

@lararennie thanks for your replay. That is the places API though, which is distinct from the basic geocoding API

crazyshakalaka commented 2 years ago

I'm also thinking about related issues How to know which component corresponds to

devng commented 2 years ago

i am facing a similar issue, i would also like to use the adr_address, but it is not available in the geocoding API @ChristianAdamski or @crazyshakalaka have you guys found a solution

ChristianAdamski commented 2 years ago

I started to map this out manually :(

https://git.drupalcode.org/project/geolocation/-/tree/8.x-3.x/modules/geolocation_google_maps/src/Plugin/geolocation/GeocoderCountryFormatting

Similarly for OSM / Nominatim & Photon:

https://git.drupalcode.org/project/geolocation/-/tree/8.x-3.x/modules/geolocation_leaflet/src/Plugin/geolocation/GeocoderCountryFormatting