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

City is null when searching address in NYC #334

Open
brandonbryant12 opened this issue Feb 28, 2022 · 4 comments
Open

City is null when searching address in NYC #334

brandonbryant12 opened this issue Feb 28, 2022 · 4 comments

Comments

@brandonbryant12
Copy link

brandonbryant12 commented Feb 28, 2022

This will return

await geocoder.geocode({
            '407 Adams Ave',
            'US',
         });
[
  {
    formattedAddress: '407 Adams Ave, Staten Island, NY 10306, USA',
    latitude: 40.5771522,
    longitude: -74.0931513,
    extra: {
      googlePlaceId: 'ChIJyfCeIsxOwokRuU1h1tTLLIs',
      confidence: 1,
      premise: null,
      subpremise: null,
      neighborhood: 'Midland Beach',
      establishment: null
    },
    administrativeLevels: {
      level2long: 'Richmond County',
      level2short: 'Richmond County',
      level1long: 'New York',
      level1short: 'NY'
    },
    streetNumber: '407',
    streetName: 'Adams Avenue',
    country: 'United States',
    countryCode: 'US',
    zipcode: '10306',
    provider: 'google'
  }
]

I have a service that depends on having the city field populated

@brandonbryant12 brandonbryant12 changed the title City is null when searching address in in NYC City is null when searching address in NYC Feb 28, 2022
@nchaulet
Copy link
Owner

nchaulet commented Mar 4, 2022

Hi @brandonbryant12 Looks like google geocoder do not return a locality component for that address what is the expected city here? to see if we can improve it and find a good fallback if there is no locality

@brandonbryant12
Copy link
Author

Hi @brandonbryant12 Looks like google geocoder do not return a locality component for that address what is the expected city here? to see if we can improve it and find a good fallback if there is no locality

This is in Staten Island NYC. Experienced the same thing for a user in the Bronx. I think it's a NYC thing afaik

@nchaulet
Copy link
Owner

nchaulet commented Mar 4, 2022

The result from google geocoder looks like this maybe we can use the sublocality as a fallback, but it need a little more investigation to be sure it's a safe fallback

"results" : [
      {
         "address_components" : [
            {
               "long_name" : "407",
               "short_name" : "407",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Adams Avenue",
               "short_name" : "Adams Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Midland Beach",
               "short_name" : "Midland Beach",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Staten Island",
               "short_name" : "Staten Island",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Richmond County",
               "short_name" : "Richmond County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "10306",
               "short_name" : "10306",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "5237",
               "short_name" : "5237",
               "types" : [ "postal_code_suffix" ]
            }
         ],
         "formatted_address" : "407 Adams Ave, Staten Island, NY 10306, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.5781923,
                  "lng" : -74.09489739999999
               },
               "southwest" : {
                  "lat" : 40.5780057,
                  "lng" : -74.09511169999999
               }
            },
            "location" : {
               "lat" : 40.5781315,
               "lng" : -74.0949888
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.5794094302915,
                  "lng" : -74.0936871697085
               },
               "southwest" : {
                  "lat" : 40.5767114697085,
                  "lng" : -74.09638513029151
               }
            }
         },
         "place_id" : "ChIJ0XTVVclOwokR7QkAK-R0HTc",
         "types" : [ "premise" ]
      }
   ]

@nchaulet
Copy link
Owner

nchaulet commented Mar 4, 2022

Looks like it could work
Screen Shot 2022-03-04 at 4 42 01 PM

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

2 participants