Skip to content

How to lookup for specific city when there are multiple returned values? #32

@stefanobartoletti

Description

@stefanobartoletti

Hi, I'm trying to lookup a specific city (Valencia, Spain), but I cannot find a way to have this library return my the exact value.

If I use

const cityLookup = cityTimezones.lookupViaCity('Valencia')
console.log(cityLookup)

I get

[
  {
    "city": "Valencia",
    "city_ascii": "Valencia",
    "lat": 39.48501752,
    "lng": -0.400012046,
    "pop": 806652,
    "country": "Spain",
    "iso2": "ES",
    "iso3": "ESP",
    "province": "Comunidad Valenciana",
    "timezone": "Europe/Madrid"
  },
  {
    "city": "Valencia",
    "city_ascii": "Valencia",
    "lat": 10.22998151,
    "lng": -67.9800214,
    "pop": 1569526.5,
    "country": "Venezuela",
    "iso2": "VE",
    "iso3": "VEN",
    "province": "Carabobo",
    "timezone": "America/Caracas"
  }
]

while if I use

const cityLookup = cityTimezones.findFromCityStateProvince('Valencia Spain')
console.log(cityLookup)

I get

[
  {
    "city": "Alicante",
    "city_ascii": "Alicante",
    "lat": 38.3512199,
    "lng": -0.483640721,
    "pop": 296345,
    "country": "Spain",
    "iso2": "ES",
    "iso3": "ESP",
    "province": "Comunidad Valenciana",
    "timezone": "Europe/Madrid"
  },
  {
    "city": "Castello",
    "city_ascii": "Castello",
    "lat": 39.97041424,
    "lng": -0.05000757,
    "pop": 176360,
    "country": "Spain",
    "iso2": "ES",
    "iso3": "ESP",
    "province": "Comunidad Valenciana",
    "timezone": "Europe/Madrid"
  },
  {
    "city": "Valencia",
    "city_ascii": "Valencia",
    "lat": 39.48501752,
    "lng": -0.400012046,
    "pop": 806652,
    "country": "Spain",
    "iso2": "ES",
    "iso3": "ESP",
    "province": "Comunidad Valenciana",
    "timezone": "Europe/Madrid"
  }
]

In both cases, I have more results that I need, and I'd like to have a way to search in example for "Valencia Spain" (to disambiguate between other cities with the same name in different countries), but without returning other cities in Spain whose name is not "Valencia"

Is it possible to do so? what exact string should I use as lookup?

Metadata

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