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

Error: No country code was found for the location #358

Open
tlokesh-enphase opened this issue Aug 23, 2024 · 1 comment
Open

Error: No country code was found for the location #358

tlokesh-enphase opened this issue Aug 23, 2024 · 1 comment

Comments

@tlokesh-enphase
Copy link

So, there is this address: latlng=50.9489119,-116.930257, for this the response received on directly hitting the google service provider https://maps.googleapis.com/maps/api/geocode/json?latlng=50.9489119,-116.930257&key=xxx is as follows:

 "results": [
    {
      "address_components": [
        {
          "long_name": "9525W3X9+HV",
          "short_name": "9525W3X9+HV",
          "types": [
            "plus_code"
          ]
        }
      ],
      "formatted_address": "9525W3X9+HV",
      "geometry": {
        "bounds": {
          "northeast": {
            "lat": 50.949,
            "lng": -116.93025
          },
          "southwest": {
            "lat": 50.948875,
            "lng": -116.930375
          }
        },
        "location": {
          "lat": 50.9489119,
          "lng": -116.930257
        },
        "location_type": "GEOMETRIC_CENTER",
        "viewport": {
          "northeast": {
            "lat": 50.9502864802915,
            "lng": -116.928963519709
          },
          "southwest": {
            "lat": 50.9475885197085,
            "lng": -116.931661480292
          }
        }
      },
      "place_id": "GhIJgqT08XV5SUARAfinVIk7XcA",
      "plus_code": {
        "global_code": "9525W3X9+HV"
      },
      "types": [
        "plus_code"
      ]
    },
    {
      "address_components": [
        {
          "long_name": "Vowell Creek Forest Service Road",
          "short_name": "Vowell Creek Forest Service Rd",
          "types": [
            "route"
          ]
        },
        {
          "long_name": "Parson",
          "short_name": "Parson",
          "types": [
            "locality",
            "political"
          ]
        },
        {
          "long_name": "Columbia-Shuswap",
          "short_name": "Columbia-Shuswap",
          "types": [
            "administrative_area_level_2",
            "political"
          ]
        },
        {
          "long_name": "British Columbia",
          "short_name": "BC",
          "types": [
            "administrative_area_level_1",
            "political"
          ]
        },
        {
          "long_name": "Canada",
          "short_name": "CA",
          "types": [
            "country",
            "political"
          ]
        },
        {
          "long_name": "V0A 1L0",
          "short_name": "V0A 1L0",
          "types": [
            "postal_code"
          ]
        }
      ],
      "formatted_address": "Vowell Creek Forest Service Rd, Parson, BC V0A 1L0, Canada",
      "geometry": {
        "bounds": {
          "northeast": {
            "lat": 50.9485088,
            "lng": -116.926709
          },
          "southwest": {
            "lat": 50.9453681,
            "lng": -116.9284635
          }
        },
        "location": {
          "lat": 50.9470167,
          "lng": -116.9278672
        },
....

Basically the first result is not having the proper details like country code, still that result is being returned and hence the error of no country code, do we have some mechanism to use some other element of results array in such cases?

@tlokesh-enphase
Copy link
Author

tlokesh-enphase commented Sep 6, 2024

I have used the raw method attribute, being sent in the response along with default result (array of length 1), for now processing those raw results internally, would be great if this library itself provides that utility.

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

1 participant