Skip to content

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

Open
@tlokesh-enphase

Description

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions